For the database deployments, I call all the db schema changes in a batch file and run them on the target database.
Sometimes we have scripts for altering the views or stored procs. I'm wondering what is the best way to control whether the view/sp has been altered successfully or not and report it via a message in the output log file.
For example below is the pseudo code of what I'd like to implement:
IF ( ALTER VIEW vw_abc . . . . ) Failed THEN PRINT 'ALTER view vw_abc Failed'. ELSE PRINT 'ALTER view vw_abc Completed Successfully' END
The output message will be recorded in the script log file which is generated by the batch file that has run the script.
If there any error code that we can check to do that? Any idea?