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 |
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-04-04 : 05:25:06
|
| insert into tableA (column1, column2, column3)select distinct c1, c2, c3 from tableBI'm scheduling a daily basis to insert into tableA.How can I avoid inserting the same data? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-04-04 : 05:31:18
|
[code]WHERE NOT EXISTS( SELECT * FROM tableA x WHERE x.c1 = tableB.c1 AND x.c2 = tableB.c2 . . . )[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
peace
Constraint Violating Yak Guru
420 Posts |
Posted - 2012-04-04 : 05:35:56
|
| Where shall I apply the Insert command? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-04-04 : 06:07:03
|
[code]insert into tableA (column1, column2, column3)select distinct c1, c2, c3 from tableBWHERE NOT EXISTS( SELECT * FROM tableA x WHERE x.c1 = tableB.c1 AND x.c2 = tableB.c2 . . . )[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|