{{theTime}}

Search This Blog

Total Pageviews

SQL to eliminate duplicates while inserting rows from source table to destination table

insert into DestinationTable
select *  from SourceTable a
 where not exists ( select 0 from DestinationTable b where b.primaryKey= a.primaryKey )

No comments:

Generate Insert Sql from Select Statement

SELECT 'INSERT INTO ReferenceTable (ID, Name) VALUES (' +        CAST(ID AS NVARCHAR) + ', ''' + Name + ''...