My table and rows as follow,declare @t1 table(idx smallint identity(1,1),cd smallint,seq tinyint,remk varchar(100));insert into @t1 values(2,1,'p1');insert into @t1 values(2,2,'p11');insert into @t1 values(2,1,'p14');insert into @t1 values(2,3,'p12');insert into @t1 values(4,1,'p15');insert into @t1 values(2,1,'p17');insert into @t1 values(5,3,'p13');insert into @t1 values(2,3,'p13');insert into @t1 values(1,3,'p13');insert into @t1 values(2,3,'p13');
So my result as follow,idx | cd | seq | remk--------------------------------------1 2 1 p12 2 2 p113 2 1 p144 2 3 p125 4 1 p156 2 1 p177 5 3 p138 2 3 p139 1 3 p1310 2 3 p13
Now, i've new table as follow. then i want to insert value in @t1 into #t1,create table #t1(idx smallint identity(1,1) primary key clustered,cd smallint,seq tinyint,remk varchar(100));alter table #t1 add constraint t1p01 unique(cd,seq);insert into #t1--select cd,seq,remk from @t1drop table #t1
How to customize my select cd,seq,remk from @t1
then, all duplicate row is not insertered.