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 |
|
ronsi
Starting Member
2 Posts |
Posted - 2007-06-26 : 02:09:01
|
| Hi...I have sp like thiscreate proc spInActiveProductasselect proid,proname where prostatus = 0 -- inactivenow i need to know affected row (@@rowcount) of that SP, i try to create spcreate proc spGetRowCountasexecute sp_sqlexec 'exec spInactiveProduct'select @@rowcountThe problem is, the result is still displayed. Is there a way, execute sp without showing the result ? I only need @@rowcount value.thanks |
|
|
pbguy
Constraint Violating Yak Guru
319 Posts |
Posted - 2007-06-26 : 02:29:18
|
| You need to change your SP design otherwisecreate a table variable with same columns as sp_inactiveproduct returnsinsert the return value to the table variable and find the count.--------------------------------------------------S.Ahamed |
 |
|
|
Koji Matsumura
Posting Yak Master
141 Posts |
Posted - 2007-06-26 : 02:30:03
|
| Why not justSELECT COUNT(*) ... WHERE prostatus = 0orYou can execute the SP into a temporary table. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-06-26 : 02:39:43
|
| Assign the @@rowcount value to a variable for further processingselect @myvar = @@rowcountPeter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-26 : 03:03:57
|
quote: Originally posted by pbguy You need to change your SP design otherwisecreate a table variable with same columns as sp_inactiveproduct returnsinsert the return value to the table variable and find the count.--------------------------------------------------S.Ahamed
You cant use table variable to get output from procedureIstead use temp tableMadhivananFailing to plan is Planning to fail |
 |
|
|
ronsi
Starting Member
2 Posts |
Posted - 2007-06-26 : 03:53:19
|
| ah...ok..temp table...thanks guys.... |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-06-26 : 04:52:59
|
| If it was me I think I would change spInactiveProduct to add an optional parameter that provides no SELECT output, but instead returns an OUTPUT parameter with the RowCountKristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-06-26 : 08:51:19
|
quote: Originally posted by Kristen If it was me I think I would change spInactiveProduct to add an optional parameter that provides no SELECT output, but instead returns an OUTPUT parameter with the RowCountKristen
Not If that procedure is used by other applications to get data MadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-06-26 : 10:05:17
|
| "Not If that procedure is used by other applications to get data"Adding a new parameter, with a default value, won't effect anything else though.Kristen |
 |
|
|
|
|
|