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 |
|
hog
Constraint Violating Yak Guru
284 Posts |
Posted - 2006-02-15 : 09:51:13
|
| I am trying to count the number of rows returned from an procedure call and get sytax errors.exec MyStoredProc returns all the rows and columns for another usage, but I can also include this in my next procedure to get the required count.I have tried this and get errors so not sure if this is possible?select count(item) from exec MyStoredProc?? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-15 : 09:54:26
|
| One possible method is to make use of @@RowCount. Immediately after running that procedure, assign that count to a variableDeclare @count as integerexec MyStoredProc Select @count=@@RowCountSelect @count -- will have the row count that sp returnsMadhivananFailing to plan is Planning to fail |
 |
|
|
hog
Constraint Violating Yak Guru
284 Posts |
Posted - 2006-02-15 : 10:04:56
|
| Oooo I was excited then, but I get zero?The proc returns 2 rows but @Count = 0? |
 |
|
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2006-02-15 : 23:30:18
|
| Check if select is the last statement to be executed in your stored procedure. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-16 : 01:59:28
|
quote: Originally posted by hog Oooo I was excited then, but I get zero?The proc returns 2 rows but @Count = 0?
Post the full code you usedMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|