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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dynamic Exec

Author  Topic 

em00guy
Starting Member

6 Posts

Posted - 2006-08-23 : 14:31:25
I have a stored procedure that outputs a string based on an integer input. Each string corrresponds to records returned by another procedure. As such, The following is what im trying to do,

SELECT users.fname, users.lname, (EXEC dbo.listOfMothers users.motherID)[maternal_heiarchy]

FROM dbo.users

Where uid = @uid


listOfMothers outputs a string of the persons mother and their mother and so on. This is what the data should look like.

fname__________lname__________maternal_heiarchy
-----------------------------------------------
jason__________foobar_________edna, margret, olga
sarah__________ishot__________hotterMom, hotForAGrama

Of course, this does not work. I hope this illustrates the principle of my efforts. I would be greatly appreciative of anyone who can help me figure out what i'm trying to do. Thanks.

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2006-08-23 : 14:36:29
you'll need a 'function' (UDF - User defined Function) instead of a procedure to do what you are attempting...

Select users.fname, users.lname, [maternal_heirarchy] = dbo.listOfMothers(users.motherId)
from dbo.users
Where uid = @uid




Corey

Co-worker on children "...when I have children, I'm going to beat them. Not because their bad, but becuase I think it would be fun ..."
Go to Top of Page

em00guy
Starting Member

6 Posts

Posted - 2006-08-23 : 15:41:58
quote:
Originally posted by Seventhnight

you'll need a 'function' (UDF - User defined Function) instead of a procedure to do what you are attempting...

Select users.fname, users.lname, [maternal_heirarchy] = dbo.listOfMothers(users.motherId)
from dbo.users
Where uid = @uid


worked brilliantly. Thanks!!

Corey

Co-worker on children "...when I have children, I'm going to beat them. Not because their bad, but becuase I think it would be fun ..."

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-26 : 05:06:16

http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -