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.
I'm trying to perform an insert query on a table, but I also want to check to see if the record exists already in the table. It should be fairly simple, but I'm having a time of it. Should be something like:select * from users uinner join miamiherald mon u.emailaddress = m.advertiseremailwhere not u.emailaddress not exists <<< (???)If it does exist, I then want to retrieve two columns from it. HELP!!
khtan
In (Som, Ni, Yak)
17689 Posts
Posted - 2006-02-18 : 09:46:28
something like this
insert into table1(col1, col2, col3)select cola, colb, colcfrom table2 twhere not exists (select * from table1 x where x.col1 = t.cola)
assuming that table1's primary key is col1----------------------------------'KH'Time is always against us