Using $(ESCAPE_NONE(JOBID)) in a Stored Procedure (SQL Server 2008 R2)

Hi All,

I've created a stored procedure that provides verbose error messages and I'm currently testing this to see if what I wrote works.  The problem I'm encountering before even starting in-depth testing, is that when I call my stored procedure, I immediately receive an error that it doesn't like $(ESCAPE_NONE(JOBID))

I'm calling this thusly: exec master.dbo.myprocedure $(ESCAPE_NONE(JOBID))

Regardless of if I try to run this manually by running the command above, or if I have this being called within a job step, the result is the same: "Incorrect syntax near 'ESCAPE_NONE'"

I've read similar posts that do the same call, however I'm not able to get this to work.  To highlight this again, I'm using SQL Server 2008 R2.  Any ideas?

Thanks.

August 28th, 2015 1:36pm

What is the $(ESCAPE_NONE) ? 

In SQL Server your should use constants or variables for parameters when calling a stored procedure.

E.g. exec master.dbo.myProcedure @JobId

Also, why did you add myProcedure to the master database? Is there a valid reason for that?

Free Windows Admin Tool Kit Click here and download it now
August 28th, 2015 1:47pm

$(ESCAPE_NONE) is an SQL Server Agent escape macro; in this particular case it, "Replaces token without escaping any characters in the string".  See the following for more details: https://technet.microsoft.com/en-us/library/ms175575(v=sql.105).aspx

My procedure expects the variable of @job_id, to which I'm trying to pass the (JOBID) token to.

August 28th, 2015 1:57pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics