Debugging stored procedures can be a headache, but heres an easier way to trace a stored procedure’s execution: Use the PRINT statement. PRINT lets you output and analyze variable values, which is sometimes good enough. Note a few restrictions when using PRINT:
- You can use only Char or VarChar data types. You must convert other data types to Char or VarChar in order to “print” them out.
- The printed string can be up to 8,000 characters long; any characters after 8,000 are truncated. (SQL Server 6.5 up to 255 characters long.)
- SQL Sever 6.5 doesn’t allow inline concatenation of variables. SQL Server 7.0 and 2000 don’t have this limitation.