March 14, 2003 at 4:42 am
Dear frineds
Itry to get the Row count with each record of the Query who can i do this is there any method in Sql server to get this
Ok Thanx
tamoor ahmad
tamoor ahmad
March 14, 2003 at 4:44 am
You can use @@RowCount
This'll tell you number of rows affected by the last transaction.
OR
Select Count(ColName) From TableName.
This'll tell you number of rows in the table (Matching the where clause if there is one)
Crispin
Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!
March 14, 2003 at 9:03 am
On a whim I thought I would try something, and lo and behold it worked! The key was to do a UNION ALL on the below query.
SELECT au_lname,
au_fname,
NULL As rowcnt
FROM pubs..authors
UNION ALL
SELECT NULL As au_lname,
NULL As au_fname,
CAST(@@ROWCOUNT As varchar) as rowcnt
Tim C.
//Will write code for food
Tim C //Will code for food
March 14, 2003 at 10:06 am
Ok, disappointment sets in. The query I posted before does not work the first time you execute it. The second time it does, because the first time you run it in the context of a new connection the @@ROWCOUNT is empty, the second time it has been filled. I am still going to play with this to see if I can work it somehow. Would be an interesting way to get summary data for report queries.
Tim C.
//Will write code for food
Tim C //Will code for food
March 14, 2003 at 11:16 am
Tim, it was a nice try, very creative.
Michael
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply