Solved

How to use Print statement  in Store procedure

Posted on 2007-11-25
5
160 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 100 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 150 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now