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 |
|
musicweekdan
Starting Member
1 Post |
Posted - 2002-05-27 : 09:52:29
|
| Hi,I am trying to run some large insert statements. Does anyone know if I can configure SQL to skip over inserting any rows that violate the tables primary key but continue inserting rows after that?ThanksDan |
|
|
Andy Verity
Starting Member
12 Posts |
Posted - 2002-05-27 : 11:00:32
|
| If each line is a straight Insert Into Values then you could put a go after each statement which would ensure that only those which are correct would run and it would not affect the rest.This will not tell you however which lines caused the problems. |
 |
|
|
dsdeming
479 Posts |
Posted - 2002-05-28 : 08:06:22
|
| How about using a where clause:INSERT INTO targettable( columnlist )SELECT columnlist FROM sourcetable WHERE pkcolumn not in( SELECT pkcolumn FROM targettable ) |
 |
|
|
setbasedisthetruepath
Used SQL Salesman
992 Posts |
Posted - 2002-05-28 : 16:27:30
|
Note that this select will not eliminate PK dups from within "sourcetable". You might consider adding a DISTINCT to the outer select.quote: How about using a where clause:INSERT INTO targettable( columnlist )SELECT columnlist FROM sourcetable WHERE pkcolumn not in( SELECT pkcolumn FROM targettable )
setBasedIsTheTruepath<O> |
 |
|
|
|
|
|