Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hiya all,i cannot get my insert staement to work what i need to do is insert data into a table but need to make sure the row does not already exist.Kind RegardsPete.
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2008-08-26 : 10:14:25
use NOT EXISTS
insert into table1(pk, col1, col2 . . .)select 100, 200, 300, . . . where not exists (select * from table1 x where x.pk = 100)