sql server insert records from one table to another -


how 1 insert records 1 table has unique index in destination table without going through insert , removal of duplicates deleting index?

insert forms(url,feedurl, dateadded) select url, feedurl, dateadded book3 t2 not exists(select * forms t1 t1.url = t2.url; t2.feedurl = t1.feedurl ,  t2.dateadded =t1.dateadded)  

violation of unique key constraint 'ix_forms'. cannot insert duplicate key in object 'dbo.forms'.

table forms

create table [dbo].[forms]( [id] [int] identity(1,1) not null, [url] [varchar](450) null, [feedurl] [varchar](450) null, [dateadded] [datetime] null,  constraint [pk_forms] primary key clustered   ( 

table book3

create table [dbo].[book3]( [url] [varchar](450) null, [feedurl] [varchar](450) null, [dateadded] [datetime] null ) on [primary] 

you may have duplicates in results set. query give fewer records orginal select?

select distinct url, feedurl, dateadded  book3 t2  not exists(select * forms t1 t1.url = t2.url  t2.feedurl = t1.feedurl ,  t2.dateadded =t1.dateadded)   

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -