To delete the Newly inserted Duplicate record :
create table ##temp (id int identity(1,1) primary key ,name varchar(100) )
insert into ##temp (name) values ('Kumar')
select * from ##temp

insert into ##temp (name) values ('Kumar')
select * from ##temp

Delete a from ##temp a,##temp b where a.id>b.id and a.name=b.name
select * from ##temp

To delete the Old inserted Duplicate record :
create table ##temp (id int identity(1,1) primary key ,name varchar(100) )
insert into ##temp (name) values ('Kumar')
select * from ##temp

insert into ##temp (name) values ('Kumar')
select * from ##temp

Delete a from ##temp a,##temp b where a.id<b.id and a.name=b.name
select * from ##temp

create table ##temp (id int identity(1,1) primary key ,name varchar(100) )
insert into ##temp (name) values ('Kumar')
select * from ##temp
insert into ##temp (name) values ('Kumar')
select * from ##temp
Delete a from ##temp a,##temp b where a.id>b.id and a.name=b.name
select * from ##temp
To delete the Old inserted Duplicate record :
create table ##temp (id int identity(1,1) primary key ,name varchar(100) )
insert into ##temp (name) values ('Kumar')
select * from ##temp
insert into ##temp (name) values ('Kumar')
select * from ##temp
Delete a from ##temp a,##temp b where a.id<b.id and a.name=b.name
select * from ##temp
No comments:
Post a Comment