|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 11:23 AM
Points: 76,
Visits: 188
|
|
Dear Experts
How to use token in sql agent job or alert to send data to operator about alert like database name for example.
Thanks lot
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 9:55 PM
Points: 6,720,
Visits: 11,759
|
|
Without more detailed information about what you are trying to do and what you have tried so far all I can do is refer you to Books Online:
Using Tokens in Job Steps
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 11:23 AM
Points: 76,
Visits: 188
|
|
Thanks for replying
I have read these info, but I need to know where should I write the token should I write it inside the job after the t-sql code step or in a seperate step or where.
Thanks lot
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 9:55 PM
Points: 6,720,
Visits: 11,759
|
|
Tokens are to be embedded within the job step command text. They are replaced at runtime with the value pointed to by the token.
From Example A in the article I linked to:
PRINT N'Current database name is $(A-DBN)' ; Put the above text into a T-SQL Job Step and run the job. Look at the job history. Then open the job and change text to:
USE msdb; PRINT N'Current database name is $(A-DBN)' ; Now run the job again and check the job history.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 11:23 AM
Points: 76,
Visits: 188
|
|
Thanks for replying
I wrote PRINT N'Current database name is $(ESCAPE_SQUOTE(A-DBN))' ; inside step, and the job is succeded, and the mail alert has sent by the operator to the target email but nothing is changed, I mean the token should send in the mail the database name but it doesnt
what do you suggest
Thanks
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 9:55 PM
Points: 6,720,
Visits: 11,759
|
|
I think you are misunderstanding. The token in the print statement will not affect the Alert email, only the output of the job step itself. If you want to send a custom email alert then call msdb.dbo.sp_send_dbmail from the job step directly. The Alert emails from Agent Jobs are not customizable.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 11:23 AM
Points: 76,
Visits: 188
|
|
Thanks
I made an output file to the step, but what is writen is
Job 'testbackup' : Step 1, 'token1' : Began Executing 2013-02-05 16:12:34
Current database name is [SQLSTATE 01000]
any suggestion
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 9:55 PM
Points: 6,720,
Visits: 11,759
|
|
Yes. Keep experimenting until you learn them. Tokens do work, I use them all the time.
__________________________________________________________________________________________________ There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Believe you can and you're halfway there. --Theodore Roosevelt
Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein
The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein
1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 11:23 AM
Points: 76,
Visits: 188
|
|
but the out file doesnt show the database name , which is used in token
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Friday, April 26, 2013 11:23 AM
Points: 76,
Visits: 188
|
|
Thanks
is job token must be runned by alert or it can be runned as normal job
Thanks
|
|
|
|