Friday, August 31, 2018

How to delete duplicate records from table in SQL Server. – SQL Interview Question

SQL सर्वर में Table से डुप्लिकेट रिकॉर्ड कैसे हटाएं। - SQL INTERVIEW QUESTION

Dear Reader,
Please click below link to see the solution of this question.

Click Here for Part - 1
Click Here for Part - 2

This is the script for your practice:

यह आपके अभ्यास के लिए Script है:
-- Query For Interview Question-3. How to delete duplicate records of a table.
create table TestQ3_1 -- Having Identity Column
(
ID int identity(1,1),
Ename nvarchar(200),
EAddress nvarchar(200)
)
Go
Insert into TestQ3_1 (Ename,EAddress)
Values('Nm1','Add1'),('Nm1','Add1'),('Nm2','Add2'),('Nm2','Add2'),('Nm3','Add3'),('Nm3','Add3')
Go

create table TestQ3_2 -- Have id column but not identity
(
ID int,
Ename nvarchar(200),
EAddress nvarchar(200)
)
Go
Insert into TestQ3_2 (ID,Ename,EAddress)
Values(1,'Nm1','Add1'),(1,'Nm1','Add1'),(2,'Nm2','Add2'),(2,'Nm2','Add2'),
(3,'Nm3','Add3'),(3,'Nm3','Add3')
Go
create table TestQ3_3 -- table with no ID column
(
Ename nvarchar(200),
EAddress nvarchar(200)
)
Go
Insert into TestQ3_3 (Ename,EAddress)
Values('Nm1','Add1'),('Nm1','Add1'),('Nm2','Add2'),('Nm2','Add2'),('Nm3','Add3'),('Nm3','Add3')
Go


Thanks.

Rudra Pratap Singh
Software Engineer.
Singhrudrapratap29@gmail.com

No comments:

Post a Comment

How to Get Organic Views on Your Channel/Content

 Hi Friends, This post will be very short and specific in the information.  If you are a content creator and want some help in getting organ...