[AccessD] SQL Server 2005 - Getting back the records affected

philippe pons phpons at gmail.com
Thu Aug 6 02:40:43 CDT 2009


Hi John,

you have a lazy google!
Here is what I just find:
==================================================
If you are running a stored procedure and it is not returning this
information then when the procedure was written the SET NOCOUNT ON flag was
set. This tells the server to not return this information back to the
client.

If you are running a standard query in the Query Analyzer or Management
Studio and you aren't getting the information back, it's because the SET
NOCOUNT ON flag has been set, either on your client as a default, or on the
server as a default. You can change this by putting SET NOCOUNT OFF in your
query above the statement that you want to see the rowcount for.

You can also request after running your query the value of the @@ROWCOUNT
variable and return this information.

UPDATE YourTable
     SET Column = 'YourValue'
 WHERE AnotherColumn = 3

 SELECT @@ROWCOUNT

=====================================================
Hope this helps!
Philippe

2009/8/6 jwcolby <jwcolby at colbyconsulting.com>

> In SQL Server 2005 when I perform an action query (Update, delete etc) how
> do I determine how many
> records were affected?  Google is not being my friend on this one.
>
> --
> John W. Colby
> www.ColbyConsulting.com
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>



More information about the AccessD mailing list