Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where does PRINT output go?

Status
Not open for further replies.

KombatKarl

Programmer
Mar 4, 2004
4
US
I am trying to troubleshoot some stored procedures. The PRINT statement would be helpful but I can not figure out where the output goes when the procedure is called from an application.

Thanks,
Karl
 
I don't think the PRINT would be readable from an application...only in query analyzer have i ever used that...
dlc
 
So other ideas on how to view sp values from an app:

1. If your stored procedure isn't currently returning a select statement, one thing you could do is build a SELECT statement inside the stored procedure, made up of variables that you want to view the values of.

So the last line of the sp would be something like:
Select @firstVar as 'FirstVariable',
@2ndVar as 'SecondVariable'

These variables could have been created anywhere inside the stored procedure. In the app you could create a recordset and view the values from there.

Hopefully that's helpful.

2. Stored Procedures can also return an integer value using the RETURN statement, which can be used in addition to a SELECT statement being returned. (See Sql Books Online under return)

3. Then there's OUTPUT variables; let me know if you need help w/ the syntax of those 'cause it can be tricky (as far as reading them from the app).

Cheers,
Ray
 
If i just need to troubleshoot, this is what I usually do; create a table in my database that I can insert strings into. Then just take a look at the contents of this table while the sp is executing.

its an easy "virtual console" (if you will) for printing statements to...you can even write a quick UDF to insert into this table, so "printing" into this table is as easy as dbo.println('starting transaction 1').

Cheyney
 
If you have access to profiler you can watch the processes through that or put the print statements in the SP and manually fire them off in Query Analyzer so you can see the print statements.

"Shoot Me! Shoot Me NOW!!!"
- Daffy Duck
 
Thanks. I know they show in Query Analyzer. The problem I sometimes come across though is usually with parameters. The SP will work when executed throguh query analyzer, but not in the application, telling me there is something different when going through a driver interface like JDBC. I was hoping to use PRINT statements to see what is going on. I like the idea of inserting values into a table.

Karl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top