devxlogo

A Simple Way to Debug a Stored Procedure

A Simple Way to Debug a Stored Procedure

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:

  1. 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.
  2. 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.)
  3. SQL Sever 6.5 doesn’t allow inline concatenation of variables. SQL Server 7.0 and 2000 don’t have this limitation.

devx-admin

Share the Post: