Using the JOBID token in 2005
$(ESCAPE_NONE(JOBID))
Here is the skinny. You can use this in a script from what I have done so far. If someone gives it a try in a stored procedure let me know. From what I have seen you can pass the token as uniqueidentifier. The problem is when you try to use it in a query you need to use Convert(char255, JOBID).
Here is a simple example:
declare @JobID uniqueidentifier
declare @result varchar(1000)
SELECT @JobID = $(ESCAPE_NONE(JOBID));
PRINT 'Hi there ' + Convert(char(255), @JobID)
I searched all over the place and nowhere did I find something like the above. It seems simple but you can do a select in a table like sysjobhistory without converting the jobid first. Let me know if this helps anyone.
Thanks
Reply:
| state_dba wrote: | |
|
What language is this?
I get an error in T-SQL.
------------------------------------
Reply:
Kalman,
You have to set SSMS to function in SQLCMD Mode from the Query Menu or the button next to Client Statistics on the toolbar to use Tokens. However, the Variable won't be populated unless it is in code being called from the SQL Agent as a job.
------------------------------------
Reply:
Okay, when you parse the statement SET @JobID = $(ESCAPE_NONE(JOBID)), you will get an error. I don't believe that you can do anything about this when working in a job step. I simply ignored the error and found that this statement with a convert on the actual value to char(255) gave me what I was looking for to extract additonal information about the job. For example since I now have the JobID I can go looking for details in the "message" field in the sysjobhistory table. This was my overall objective in the first place. So in short you must first dump the JobID into a uniqueidentifier data type and then use the convert(char(255), uniqueidentifier/jobid) to get a value that can be used in a query on the fly.
Snippet:
declare @servername varchar(200)
declare @detail varchar(1000)
declare @mxid int
declare @JobID uniqueidentifier
SET @JobID = $(ESCAPE_NONE(JOBID));
The whole solution:
BEGIN TRY
declare @servername varchar(200)
declare @detail varchar(1000)
declare @mxid int
declare @JobID uniqueidentifier
SET @JobID = $(ESCAPE_NONE(JOBID));
SET @mxid = (SELECT MAX(instance_id)
FROM [msdb].[dbo].[sysjobhistory]
WHERE job_id = Convert(char(255), @JobID)
AND step_id = 1)
SET @detail = (SELECT [message]
FROM [msdb].[dbo].[sysjobhistory]
WHERE job_id = Convert(char(255), @JobID)
AND step_id = 1 AND instance_id = @mxid)
-- send details about the job
DECLARE @rc INT
IF NOT EXISTS (SELECT * FROM msdb.sys.service_queues WHERE name = N'ExternalMailQueue' AND is_receive_enabled = 1)
EXEC @rc = msdb.dbo.sysmail_start_sp
SET @servername = 'Job Detail From ' + @@servername
EXEC msdb.dbo.sp_send_dbmail @recipients='validemail@email.com', @importance = 'High', @profile_name = 'valid_profile',
@subject = @servername,
@body = @detail,
@body_format = 'TEXT';
END TRY
BEGIN CATCH
END CATCH
------------------------------------
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
-Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 9:23 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
-Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 9:24 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
-Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 9:25 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
-Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 9:28 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
-Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 9:30 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
-Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 9:31 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
-Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 9:32 PM not question
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 9:33 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
-Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 9:34 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
-Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 9:57 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
-Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 9:58 PM not question
COM surrogate stops working
But "com surrogate error" came back.
Then I saw that I had an AVI movie with a special Icon, i.e. no more the first image of the movie; only the symbol of the movie reader. I deleted the movie and I had no problem any longer. Maybe is the origin of the movie I got from a friend contained a virus (not detected by Norton) or was corrupted.
I think the answer lays somewhere there.
This forum has moved
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 10:00 PM not question
- Edited by Andrew BrennerMicrosoft employee Friday, October 24, 2008 9:52 PM forum has moved
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 10:02 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
Andrew
- Changed type Jian-Ping Zhu-MSFT Thursday, June 5, 2008 9:31 AM notification
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 10:09 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
Andrew
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 10:11 PM not question
This forum is moving the week of 5/27
Microsoft has created a new forums platform (MSDN | TechNet | Expression | Microsoft) with increased performance, stability, and an improved user experience. During the week of 5/27 this forum will be moving to the new platform. To make sure this is a smooth transition, we want everyone using this forum to have a chance to try out the new forums in advance, and give feedback. We've created a Sandbox forum, where you can create threads and try out functionality, and a suggestions forum where you can give us your feedback. Please take some time to go to the new forums today and let us know what you think.
On the day the forum moves to the new platform, a post will be made letting you know the process has been started, and the forum will be locked to new posts. Once the process is complete, a final post to the forum will be made letting you know the forum has moved.
1. All posts in the forum will be preserved
2. Any points you've received for replies will move with you (on a per forum basis)
3. Any bookmarks to this forum or threads within this forum will redirect to their new location
4. Your "My Threads" will be preserved on the new platform
The only thing you'll need to do after migration is set Windows Live Alerts for any threads you were tracking.
If you have feedback, let us know in the suggestions forum or contact me directly at Andrew.Brenner at Microsoft.com
Thanks,
Andrew
- Changed type Andrew BrennerMicrosoft employee Tuesday, June 3, 2008 10:13 PM not question
Amd Processor Resolution to incesssant reboots after SP3 Installations
Hello All,
This forum is going to get a lot of hits for the reboot issues. The following fix should work for any machine with an AMD Processor. If you have an AMD processor then there are a few easy steps that should correct the problem. The problem is that SP3 loads a file called intelppm.sys. This file is for use only for the Intel processors power management. This is a driver system file so it will not load when going into safe mode. When your computer reboots and is at the black screen hit the f8 key to get into the boot selection menu. Elect the Safe mode with networking option. When system boots up in safe mode. Perform the following run command.
select:
Start
Run
type in the command box:
sc config intelppm start= disabled
then you should be able to reboot normally.
Will post more as the learning curve grows.
Have a nice day
Reply:
Hp media center a1310n didn't work for me BSOD came up with five stop errors...
0x0000007e (0x0000005,0xf7730756,0xf798b42c,0xf798b128)
so now what????
------------------------------------
Reply:
got the hp going by install with msconfig in dianogists mode and with fix applied after install not before...
------------------------------------
No comments:
Post a Comment