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.
| Author |
Topic |
|
shifis
Posting Yak Master
157 Posts |
Posted - 2009-09-11 : 15:04:28
|
| Is posible to obtain the result of a select stament in a varible?Example:(291989 row(s) affected) |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-09-11 : 15:08:28
|
| It is already captured in the global variable: @@rowcountBe One with the OptimizerTG |
 |
|
|
shifis
Posting Yak Master
157 Posts |
Posted - 2009-09-11 : 18:08:36
|
| Thanks,I am checking some stores that make a select to send information and then make a count of the select to obtain the number of rows sending. |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-09-11 : 18:58:51
|
| Just be careful because that value is reset after every statement. So:select * from sysobjectsselect @@rowcountselect @@rowcountThe second "select @@rowcount" will return 1. Because that was the rows affected from the first "select @@rowcount". If you need to save the value for a few statements then capture it in your own local variable:declare @myRowcount intselect * from sysobjectsset @myRowcount = @@rowcountNow you have your version for as long as you need.Be One with the OptimizerTG |
 |
|
|
|
|
|