views:

1636

answers:

3

I've got SQL Server jobs running that include periodic 'print' statements so that I can look in the job history and get a sense of what happened. But the output is cluttered with [SQLSTATE 01000]. Given that there is a limit to how much will fit in this output, I'd like as much space as possible for information I care about.

Is there any way to suppress the [SQLSTATE 01000] output for 'print' commands?

A: 

You're probably out of luck. That is normal output for PRINT statements. I don't think there is any way to suppress them.

Mitch Schroeter
A: 

Not positive if you wanted to remove just the [SQLSTATE 01000] from the output or anything which contained [SQLSTATE 01000]. So here is both ways.

Print replace(@PrintThis, '[SQLSTATE 01000]', '');

Basically this will replace [SQLSTATE 01000] with nothing.

The next useses CHARINDEX(expression1, expression1 [, start_location]), Searches expression2 for expression1 and returns its starting position if found. The search starts at start_location.

@result = CHARINDEX('[SQLSTATE 01000]', @PrintThis)
if (@result > 0)
    Print @PrintThis

So if CHARINDEX < 0 the string [SQLSTATE 01000] doesn't exist and it doesn't print

If missed what you are trying to do please respond as such.

I hope this helps,

Brett

Brettski