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 |
|
raysefo
Constraint Violating Yak Guru
260 Posts |
Posted - 2011-03-01 : 06:55:49
|
| Hi,I want to insert into a table but I would like to check if there is same data already in the table. Is there a way to do this in a single insert statement? And I would like to know if checking for duplicates is expensive within 10000 data?thanks in advance.Best Regards |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-03-01 : 07:41:05
|
No IF needed.Example:insert destinationtable(col1,col2,col3)select col,col2,col3from sourcetable t1where not exists(select * from destinationtable t2 where t1.col1 = t2.col1) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
raysefo
Constraint Violating Yak Guru
260 Posts |
Posted - 2011-03-01 : 07:58:27
|
| Thanks webfred for your reply, Is this too slow and waste of too much resources? |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-03-01 : 07:59:20
|
No, I don't think so Give it a try. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|