Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Debugging Procedures

Author  Topic 

IMGrumpy
Starting Member

11 Posts

Posted - 2010-12-01 : 09:31:36
Greetings:

Is there a way to get an SQL Procedure to produce some sort of output to a debug stream (text file or console) when the procedure runs?

I have found the PRINT statement and this is useful for when the SCRIPT executes. But all the script is doing is installing the procedure into the database. What I would like is a PRINT or TRACE statement to direct output to a file or console output when the procedure actually executes. That is, when my client .NET application invokes this procedure.

Thanks in advance to anyone that responds.
Mark

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-12-01 : 09:40:46
You could use the profiler.

I always create a trace table and put logging statements in the SPs to monitor progress and performance
Trace (id, dte, entity, key1, key2. key3, data1, data2, data3)
For an SP entity is the sp name - I log start and end in key1 - everything else has a value in key1 and usually some dta items (row counts etc.)
key2, key3 I use for loops.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-12-01 : 12:27:12
if you want to test the proc from .NET appln, you can create a test harness app in your .NET to call the proc passing reqd params and checking the return values/resultset

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -