Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to use Print statement  in Store procedure

Posted on 2007-11-25
5
Medium Priority
?
186 Views
Last Modified: 2010-04-21
I have a store procedure with a Print Statement,

ALTER Procedure [dbo].[sp_ProcessImage]
      @Err int OUTPUT
      
As
declare @rowPro integer      -- 1 row must be Updated
                                                
select @Err = 1      
Begin Tran

INSERT INTO Asset
( .....

select @rowPro = @@rowcount
      
if @rowPro <> 1 or @@error != 0
      begin
            Rollback Tran
            select @Err = 1
            return
      end
Commit Tran
      select @Err = 0      
      return

print 'Rowpro=' + @rowPro


After I run procedure I hope I can get 'Rowpro=1', but I didn't get anyting print out. How I can trace the value of a variable inside procedure?  
0
Comment
Question by:dshi15
  • 2
  • 2
5 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 20346325
put the print statement before the 'return statement'


Commit Tran
      select @Err = 0      
 
print 'Rowpro=' + @rowPro

    return
0
 
LVL 1

Author Comment

by:dshi15
ID: 20346358
Hi,
I forgot how to convert int.

print 'Rowpro=' + convert(@rowPro,varchar(25)) is not work. thanks.
0
 
LVL 35

Assisted Solution

by:David Todd
David Todd earned 400 total points
ID: 20347750
Hi,

Your convert is back-to-front

print 'Rowpro = ' + convert( varchar( 25 ), @testInt )

and dont forget to put it _before_ the return!

Cheers
  David
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 600 total points
ID: 20347818
print 'Rowpro=' + cast (@rowPro  as varchar(25))
0
 
LVL 1

Author Closing Comment

by:dshi15
ID: 31410866
thanks
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Screencast - Getting to Know the Pipeline

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question