Job Step Tokens
SQL Agent offers job tokens??”a great feature I rarely see used. Essentially, these system
functions act as variables only when they appear in job steps. The variables can be
extremely useful when defining job steps. Here are a few of the available tokens:
CHAPTER 5 n CREATING A BACKUP/RECOVERY PLAN 116
??? Current date (DATE)
??? Current time (TIME)
??? Message number (A-ERR)
??? Message text (A-MSG)
??? Server name (A-SVR)
??? Instance name (INST)
??? Database name (A-DBN)
These tokens aren??™t new to SQL Server 2005, but their syntax has changed with the
addition of Service Pack 1 (SP1) for SQL Server 2005. Previously, you simply placed these
tokens into square brackets in the job step text:
BACKUP DATABASE AdventureWorks TO DISK='E:\backupdata\aw[DATE][TIME].bak'
With SQL Server 2005 SP1, you now also enclose job-step tokens in parentheses
preceded by a $ within an ESCAPE_NONE macro:
BACKUP DATABASE AdventureWorks TO
DISK='E:\backupdata\aw$[(ESCAPE_NONE(DATE))][$(ESCAPE_NONE((TIME))].bak'
I use tokens quite a bit, which is a bit odd for me since they aren??™t for the syntactically
challenged (and that would definitely be me).
Pages:
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245