Enter into database only new values found in the SQL statement, skip the ones already

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hammad khan
    New Member
    • Nov 2011
    • 1

    Enter into database only new values found in the SQL statement, skip the ones already

    How can i write SQL INSERT IntO Statement that will add in the database only new values in the database, and skip the ones already in the database?

    Thanks
  • Maraj
    New Member
    • Nov 2011
    • 24

    #2
    Try this may it work for you
    Code:
    insert into new database.dbo.table_name select * from old database.dbo.table_name where
     old database.dbo.table.Primary Key not in 
    (select  new database.dbo.table.Primary Key from  new database.dbo.table)

    Comment

    Working...