Viewing print output from a Stored Procedure in SQL Server Management Studio

So, I've got Microsoft SQL Server Management Studio 2008.

In the "old" days (earlier version, probably Visual Studio 2005), I had PRINT statements in my stored procedure and I could execute the SP and see all the print statements in an output window.

Now, when I execute a SP, I don't see these print statements, even in the Messages window.

Any suggestions?

Thanks,

Steve
skbohlerAsked:
Who is Participating?
 
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
if any of the values for example '@ITEMTYPEIDENTIFIER '  is null , then the string catenation will result in null,

PRINT @ITEMID + ' | ' + ISNULL(  cast( @ITEMTYPEIDENTIFIER as varchar ) , '' )
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
Hello skbohler,

its still available with the sql server management studio,




Regards,

aneeshattingal
0
 
skbohlerAuthor Commented:
How?

Where is the output viewed?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Aneesh RetnakaranDatabase AdministratorCommented:
try running the stored procedure from sql server mangement studio,

you can test  even running the following statement

print 'hello world'
0
 
skbohlerAuthor Commented:
I think the problem is with print statements that used to work but don't, like:

PRINT CAST(@ITEMID AS CHAR(5)) + ' | ' + CAST(@ITEMTYPEIDENTIFIER AS CHAR) + ' | ' + @ITEMTEXT + ' | ' + CAST(@THRESHOLDLOW AS CHAR) + ' | ' + CAST(@THRESHOLDHIGH AS CHAR) + ' | '  + CAST(@TMPSCORE AS CHAR) + ' | ' + CAST(@UNADJUSTEDSCORE AS CHAR) + ' | ' +  CAST(@RESULT AS CHAR)

If I just try and use:

PRINT @ITEMID + ' | ' @ITEMTYPEIDENTIFIER

it generates an error. That is why I put in the CAST statements, and those work in the output of Visual Studio.

Again, simple PRINT statements do work (like PRINT @ITEMID).

Any ideas why the more complex print statement wouldn't produce any results in Management Studio?

Steve
0
 
skbohlerAuthor Commented:
I'll try that and let you know. Thanks.
0
 
Mark WillsTopic AdvisorCommented:
Also if they are numeric it wont concatenate either, and it is probably important to see if any of them are NULL

best is open a query window (short cut key CTRL+N) do your declarations, then paste the code :

print isnull(convert(varchar,@ITEMID),'NULL') + '|' + isnull(convert(varchar,@ITEMTYPEIDENTIFIER),'NULL')

then when you run it (shortcut key F5) you should get the tab pages down the bottom - at least one of which will be 'Messages' that is where the print will go (as well as any errors, and other messages, etc).

So as an example try pasting the whole lot (below) and press F5 :

declare @ITEMID int
declare @ITEMTYPEIDENTIFIER int

print isnull(convert(varchar,@ITEMID),'NULL') + '|' + isnull(convert(varchar,@ITEMTYPEIDENTIFIER),'NULL')

set @itemid = 1

print isnull(convert(varchar,@ITEMID),'NULL') + '|' + isnull(convert(varchar,@ITEMTYPEIDENTIFIER),'NULL')

set @itemid = 2
set @itemtypeidentifier = 2

print isnull(convert(varchar,@ITEMID),'NULL') + '|' + isnull(convert(varchar,@ITEMTYPEIDENTIFIER),'NULL')

--results should be three lines in the 'messages' tab (without the leading hyphens of course)
--NULL|NULL
--1|NULL
--2|2
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.