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.
Author |
Topic |
Shem
Yak Posting Veteran
62 Posts |
Posted - 2007-02-12 : 03:12:49
|
Morning,I'm trying to insert a record ONLY if it does not already exist.though i can't seem to find a simple solution, have looked all over the net already :(how can do you write a statement to first check for the values you are trying to enter, and if thevalues not exists then perform the insert into?if a simple example can be given, I would greatly appreciate it.ThanksShem |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-12 : 03:19:46
|
[code]insert into table1 (pkcol, col2, col3 . . )select @pkcol, @col2, @col3, . . where not exists (select * from table1 x where x.pkcol = @pkcol)[/code] KH |
 |
|
|
|
|