June 28, 2013 at 9:41 pm
Hi..
I have a table and need insert multiple data into it. First i have delete all data into the table and then insert multiple rows in table using sql transactions so that if any error comes all data will not be deleted.
Thanks and Regards
Sankar
Cochin
June 29, 2013 at 3:49 am
sankar.nandakumaran (6/28/2013)
Hi..I have a table and need insert multiple data into it. First i have delete all data into the table and then insert multiple rows in table using sql transactions so that if any error comes all data will not be deleted.
Thanks and Regards
Sankar
Cochin
The quick answer for >SQL2008 would be something like:
BEGIN TRAN
[MERGE with INSERT. UPDATE, and DELETE]
END TRAN
Check out these articles:
Using the MERGE Statement[/url]
June 29, 2013 at 5:12 pm
For a single command (MERGE is a single command) you do not need "begin tran",
each command starts implicit transaction, and commits/rollback implicitly, all the time (if not within larger transaction).
Also, there is no "end tran" command, you probably meant "commit tran".
June 30, 2013 at 9:52 am
Vedran Kesegic (6/29/2013)
Also, there is no "end tran" command, you probably meant "commit tran".
You are correct about COMMIT TRAN. It was late after a long day! :blush:
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply