help with output parameter in a stored procedure

Posted on 2007-08-10
Last Modified: 2013-11-05
hi, I would like to add an output parameter to this stored procedure.

I would need output param to be valorized with the 'records affected' value

Thanks and regards
Question by:repzat
    1 Comment
    LVL 142

    Accepted Solution

    create procedure backup_Proc
    ( @rows_affected int OUTPUT )
           insert into tableC (field1, field2, field3, field4)
           select B.field1, B.field2, B.field3, B.field4 from  A,B
                  where A.guid = B.guid
                         and A.deleted = 1

             delete B from  A,B
                  where A.guid = B.guid
                         and A.deleted = 1
    SET @rows_affected = @@ROWCOUNT

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    732 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

    25 Experts available now in Live!

    Get 1:1 Help Now