Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 @@ROWCOUNT in parallel mode

Author  Topic 

chetanb3
Yak Posting Veteran

52 Posts

Posted - 2014-04-07 : 13:26:35
Does @@ROWCOUNT works if i have two parallel threads inserting deleting on smae table??

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-04-07 : 13:47:23
If you are referring to the query being parallelized by the query optimizer, then when you examine @@ROWCOUNT after the completion of the query, it will correctly show the number of rows affected regardless of which thread(s) caused the rows to be affected.

If you are referring to the case where two separate spids are making changes to a table, each spid will show the rows that was affected in the query it executed.
Go to Top of Page

sqlsaga
Yak Posting Veteran

93 Posts

Posted - 2014-04-07 : 16:49:27
two separate windows (two separate spid's) -- @@rowcount depends on the amount of data inserted in that window.
same window separate queries -- will show number of rows affected.

Visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.
Go to Top of Page

chetanb3
Yak Posting Veteran

52 Posts

Posted - 2014-04-08 : 01:57:27
Thanks, It means @@ROWCOUNT works SESSION wise just like a simple variable.
Go to Top of Page
   

- Advertisement -