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 |
|
avijit_mca
Posting Yak Master
109 Posts |
Posted - 2010-07-06 : 03:25:22
|
| i am running a while loop & passing a varialbe for source/destination table name. insert into @sourcetableselect * from @dest_tablenow say in 10th no table having some problem & for that its fail operation after inserting 100 rows.in that case what will happen?How i will fix the bug?I want to run this package again but this time insert operation should start from 10th no table instead of start 1 st table. and also it should start from 10th no table from 100 rows. In ssis package its possible by using check point, but what about T-SQL?Regards,avijit |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-06 : 03:33:26
|
useWHERE NOT EXISTS(...)to insert only records that are not already in the destination table. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
avijit_mca
Posting Yak Master
109 Posts |
Posted - 2010-07-06 : 03:43:16
|
| i inserting 500000 rows into table, but after insert 20000 rows , due to some problem abort transcation . now if i again run the code it should not start inserting value from 1..it should start from 20000 no row.But if transcation failed , in general it will rollback all inserted value???Regards,avijit |
 |
|
|
KrafDinner
Starting Member
34 Posts |
Posted - 2010-07-06 : 09:29:32
|
check for error status and rollback the transaction, if that's what you want it to do...You can use a couple of easy things to be sure it will do what you want.SET XACT_ABORT ONBEGIN TRANSACTION{Your code here}COMMIT TRANSACTIONThis will set it to rollback the transaction if any error is encountered.Combine this with the where not exists clause mentioned above and I would think you should be all set. |
 |
|
|
|
|
|