How can I stop the execution of TSQL script through tsql script?
I have the following script designed to stop our developers accidently running our db modfication scripts against the wrong database. I recently discovered that this only halts the running of the current batch. What can I replace the 'return' with to stop execution altogether?
--In this example I want to stop the 'select * from sysobjects' statement from being run without removing the 'go'.
IF db_name() IN ('master','model','msdb','tempdb')
RAISERROR('YOU ARE ATTEMPTING TO RUN THE DBMODS AGAINST THE WRONG DATABASE!',16,1)
Select * From sysobjects