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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

when running a stored procedure can I print debugging statements

Status
Not open for further replies.

mit99mh

Programmer
Sep 24, 2002
246
GB
I'm new to sql server so assume nothing!

when running a stored procedure can I print debugging statements defined in the stored proc to the query analyser

eg

CREATE PROCEDURE CS_insertUsers
@id int
AS

if exists( SELECT id FROM CS_users )
begin
// print to query analyser "id found "
return (0)
end
GO
Any help much appreciated
 
What I've seen suggested (and have done on longer SP's I have created) is to add a "debug" parameter to your SP:

create proc proc_name @parm1, @parm2, ... @parmN, @debug bit
as

if @debug = 1
begin
print 'declare variables'
end

declare @var1,
@var2,
...
@varN

if @debug = 1
begin
print 'check to see if @parm1 exists'
end

if exists (select * from tbname where f1 = @parm1)

etc
etc


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top