June 27, 2012 at 12:24 pm
I am trying to create a job step, dynamically. I would like to put a line break\carriage return, after a comment line. So, for example, in my job step, I want:
-- Some Comment
SELECT GETDATE()
I have a variable I am populating, to use on the input to the job step.
DECLARE @Command NVARCHAR(1000)
SET @Command = '--My Comment ' + 'SELECT GETDATE()'
The result, when I look in the job step is --My Comment SELECT GETDATE()
Which is what I expected, so I tried using CHAR(10) and CHAR(13).
SET @Command = '--My Comment ' + CHAR(13) + 'SELECT GETDATE()'
but I get the same result, no line feed or carriage return, just a single line.
Is it possible to put the carriage return or new line feed when creating a job step dynamically?
Thanks,
Leonard
June 27, 2012 at 1:19 pm
lrutkowski (6/27/2012)
I am trying to create a job step, dynamically. I would like to put a line break\carriage return, after a comment line. So, for example, in my job step, I want:-- Some Comment
SELECT GETDATE()
I have a variable I am populating, to use on the input to the job step.
DECLARE @Command NVARCHAR(1000)
SET @Command = '--My Comment ' + 'SELECT GETDATE()'
The result, when I look in the job step is --My Comment SELECT GETDATE()
Which is what I expected, so I tried using CHAR(10) and CHAR(13).
SET @Command = '--My Comment ' + CHAR(13) + 'SELECT GETDATE()'
but I get the same result, no line feed or carriage return, just a single line.
Is it possible to put the carriage return or new line feed when creating a job step dynamically?
Thanks,
Leonard
I'm not sure I understand the question. You are storing string data into a variable. When the step is created, it is created as an unformatted string.
Jared
CE - Microsoft
June 27, 2012 at 1:43 pm
I finally got it to do what I wanted.
When I populate the string, I had to do this:
SET @Command = N'--My Comment
SELECT GETDATE()'
Not this:
SET @Command = N'--My Comment ' + CHAR(13) + 'SELECT GETDATE()'
I guess that only works when creating text data output, which is what I wanted.
But it's working, so I can live with that.
Thanks,
Leonard
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply