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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 insert statement

Author  Topic 

petek
Posting Yak Master

192 Posts

Posted - 2008-08-26 : 10:11:39
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 Regards

Pete.

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)



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -