Is it good to test SQL scripts with ROLLBACK at the end of the script?

I need to write some SQL update scripts to add tables, rename columns, etc. I put everything inside a transaction:

IF EXISTS (/* check version */)
BEGIN
    -- print cannot apply update
END
ELSE
BEGIN
    BEGIN TRANSACTION

        -- apply updates

    ROLLBACK
    --COMMIT
END

Now, if I ROLLBACKupgrade instead COMMIT, can I assume that later, when I put it back in COMMIT, it will work? I don't want to apply it to my dev database yet, but I can click F5and check if everything is ok.

+4
source share
1 answer

, , . script, / SQL, , . , SQL, , ( SQL ) SQL , - - .

SSV ( ): , - . .

+1

Source: https://habr.com/ru/post/1612734/


All Articles