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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-08-30 : 10:45:28
|
| Zach writes "I've got a sProc that does a lot of calculations (and execs other sProcs w/in it) and will provide me with data that I need to use in another procedure I'm creating. The problem is that it creates quite a long record, and I don't need nearly all the columns.It returns 1 record with 42 columns, when I need about 4 or 5 of those at most. Is there a way that I can insert into a temp table ONLY those 4 or 5 columns that I need from the sProc, *without* using output parameters (the existing sProc that I want to make use of is used by several different pages and applications, so I do not want to change the signature of it)Once again, this is being done *within* a different sProc.Flow:create main sProc ( vars defined)vars declared/selectedinitial data manipulation/calculationsLARGE Data sProc executedManipulation of data returned by the sProc.Please feel free to email me if there are any questions about what I've submitted... and thank you for your service!" |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2006-08-30 : 10:53:49
|
| not without output params, or simply rewriting the proc. Shove the results into a temp table, then just select the columns that you need from that temp table.For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-08-30 : 10:56:48
|
| Isn't this a question that turned up some time ago?Add an optional parameter to the sp.If that parameter is not set to the default (set default as null) then return just the 4-5 cols otherwise the existing resultset.Then you call with the parameter - the existing code will call without the parameter which will use the default and get the existing resultset.The only problem might be if anything gets the parameter list and doesn't realise it can let this one default.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|