Can I run an sql script for db upgrade using transaction?

73 views Asked by At

I need to run a 56000 lines sql server db upgrade script in SQLCMD mode, because if it fails I need to continue from the first error line, and I'm not allowed to run anything twice.

Can I run the entire script using one 'begin transaction' line, without committing anything, so that after working through all errors one at a time, I'll be able to rollback and then run the entire script to see that it works properly before committing? and if so, should it be my very first line? before use <db_name> and :on error exit

I already did the process and completed the upgrade but did not save the code into one correct file. so I gotta start over, and want to make sure I do it right this time.

also, will rollback discard any changes made within the script? including table structure?

0

There are 0 answers