Get number of rows affected

Posted on 2008-11-12
Last Modified: 2012-05-05
Is it possible when running an update/delete Query to grab the message xx row(s) Affected? when performing an exec statement?
Question by:joachimcarrein
    LVL 92

    Accepted Solution

    After running an update/delete/insert statement, interrogate @@ROWCOUNT:

    SELECT CONVERT(varchar(20), @@ROWCOUNT) + ' rows affected'
    LVL 22

    Expert Comment

    after update add:
    SELECT @@ROWCOUNT as RowsNumber
    LVL 4

    Author Comment

    stupid of me that i forgot this one...

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

    754 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

    21 Experts available now in Live!

    Get 1:1 Help Now