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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need To pull a select few results from INSERT EXEC

Author  Topic 

Phrozt
Starting Member

8 Posts

Posted - 2006-08-17 : 16:48:27
I'd *like* to execute a sProc within another sProc, because this other one (let's call it dataProc) will provide me with results I need that are calculated based off execing other procs within that proc itself.

I'd like to use this data in a new sProc (we'll call it newProc), but I don't need NEARly all of the columns. The dataProc returns 1 row with 42 columns. I need about 4-5 of those for my newProc.

The dataProc does not have any output variables, and I do not want to change the signature, because several pages/apps use this existing dataProc.

My question:
Is there a way to INSERT INTO table EXEC dataProc
*Without* making a temp table that takes in every single column the dataProc puts out?

Any help is much appreciated.. thanks!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-08-17 : 16:58:08
Check out spirit1's solution in this post:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=70685

I personally don't like it, but it works. It requires a linked server.

Tara Kizer
Go to Top of Page

Phrozt
Starting Member

8 Posts

Posted - 2006-08-17 : 17:05:09
yeah.. I definately don't want to use a linked server, and I saw someone mentioning the INSERT INTO table EXEC method, but not how to insert only a handful of the columns returned by the sProc..
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-08-17 : 17:12:18
That was me mentioning the INSERT INTO EXEC method.

It is not possible to insert only a handle of the columns returned by a stored procedure.

Tara Kizer
Go to Top of Page

Phrozt
Starting Member

8 Posts

Posted - 2006-08-17 : 17:18:57
Ahh.. well, thank you... that's what I needed to know for sure...
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-08-18 : 08:58:15
so why not write your own version of this stored proc, and return the few columns that you need?

For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

Phrozt
Starting Member

8 Posts

Posted - 2006-08-18 : 09:02:57
We already have more sProcs in our databases than there are emos in the world...

yeah...

I try to do what I can to cut down on making mirrors of sProcs that do almost exactly what another does, but just slightly different
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2006-08-18 : 09:31:37
You could add an optional parameter to the proc and if it's set only return the abbreviated set.

==========================================
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.
Go to Top of Page

Phrozt
Starting Member

8 Posts

Posted - 2006-08-18 : 09:56:06
Now THAT is an excellent idea!!

Thank you very much for the idea
Go to Top of Page
   

- Advertisement -