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 |
|
codrgiii
Starting Member
29 Posts |
Posted - 2009-05-30 : 18:17:36
|
| how do i insert into a table and only inserting once if there are more than one of the same value in that table/column? i want it to only insert once if there are more than one of the same value, to avoid inserting duplicate values yet still inserting other values from that column to the table without terminating the script, how do i do this? |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-05-30 : 19:09:53
|
| If you mean that your source table has duplicates then construct your SELECT statement such that only one value is selected using GROUP BY or DISTINCT.If you mean that your target table already has one or more of the values from your source table then use either a LEFT OUTER JOIN where the left table (target table) is NULL. OR use a WHERE NOT EXISTS clause.If you need specifics then post your code.Be One with the OptimizerTG |
 |
|
|
codrgiii
Starting Member
29 Posts |
Posted - 2009-05-30 : 21:00:31
|
| what would be the syntax for that? |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-05-30 : 21:29:08
|
| I think all the scenarios I mentioned are in these examples. Get used to using Books Online. It's a great resource.http://msdn.microsoft.com/en-us/library/ms187731(SQL.90).aspxBe One with the OptimizerTG |
 |
|
|
|
|
|