To test the A- tokens, in a test
environment of course:
- Setup a job that has the PRINT statement from Example A from the article I posted earlier.
PRINT N'Current database name is $(ESCAPE_SQUOTE(A-DBN))' ;
- Setup an Alert that fires for Database Errors with Severity 16 that starts the job you just created.
- Run this in a Query window which should prompt the job to execute, per the Alert:
RAISERROR('hi',16,1) WITH LOG;
- Check the job history to make sure it ran and check the step history to see the output of the PRINT statement.
- Now change databases and raise the error again.
- Again check the job history to make sure it ran and check the step history to see the output of the PRINT statement has changed to show the new database context.
__________________________________________________________________________________________________There are no special teachers of virtue, because virtue is taught by the whole community. --Plato