08 July 2016 Sudhanshu Ranjan 1.35k
Display data which has two or more than two times in table in sql server.
This is very simple query that you can easily understand. How we are faching the data who has two or more than two times in table.
Here is Employee Table.
CREATE TABLE [dbo].[Employee]( [EmployeeId] [int] IDENTITY(1,1) NOT NULL, [EmployeeName] [varchar](50) NULL, [Salary] [int] NULL, [Gender] [varchar](50) NULL, [Address] [varchar](250) NULL, [RegistrationDate] [datetime] NULL, CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED ( [EmployeeId] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO
We have some record in this table and there is some record which has duplicate.
SQL Script to get the record which has two or more than two times.
SELECT EmployeeName FROM Employee GROUP BY EmployeeName HAVING COUNT(*)>=2
Sudhanshu Kumar Ranjan | Lead Engineer at HCL Technologies | Expertise in Microsoft Technology | Author | Blogger | Programmer
Connect with him on Facebook | Google+ | LinkedIn | Twitter
- What is the Difference between Overriding and overloading
- Difference between ref and out parameters with example.
- Redirect URL non-www to www using web.config in MVC ASP.Net
- secure connection failed firefox fix
- Angular : Understanding about all files and folders created by Angular CLI
- Get manager name in employee table mostly asked in interview question
- What is cursor in SQL Server with example.
- What is the difference between UNION and UNION ALL?
- NULLIF Function in SQL Server with example
- What is static Constructor? Explain.
Leave a comment
Search In This Website
- TypeError: $(...).autocomplete is not a function
- Paging in MVC using C# with razor
- How to use CKEditor in MVC application/ Asp.net application.
- Bind dropdown in MVC using jquery with C#
- How to implement CAPTCHA in MVC 4 using C# Asp.net.
- set default page while using “Area” in MVC application
- Create and consume a simple WCF Restful service using AngularJs application
- datepicker textbox in mvc 4 using JQuery
- How to install asp.net mvc 5 in visual studio 2012
- Bind gridview and paging example in angularjs
- Sql Server(9)
- Entity Framework(3)
- Angular Js(7)
- Web API(0)
- Web Service(1)
- Crystal Report(0)
- My SQL(5)
- Visual Studio(18)
- Knockout JS(0)
- Microsoft Office(0)
- Node JS(0)