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 2000 Forums
 SQL Server Development (2000)
 @@rowcount

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-03-19 : 08:29:52
mustafa güney writes "i want current value of rowcount to return my select list in sql query

how to return current rowcount to select list"

raymondpeacock
Constraint Violating Yak Guru

367 Posts

Posted - 2004-03-19 : 08:44:58
There is no variable equivalent to @@Rowcount that you can list in the result set. You will have to either do an initial count into a variable then include it in your results set like this:

SELECT @Rows = COUNT(*) FROM Products
SELECT P.*, @Rows FROM Products

remembering that if you use a WHERE clause you need to specify it in both SELECTs.

Or you could issue one query like this

select S.ReturnedRows, P.*
from Products P, (SELECT COUNT(*) AS ReturnedRows FROM Products) S




Raymond
Go to Top of Page
   

- Advertisement -