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)
 returns from dynamic stored procedures

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-11 : 08:14:05
glen kania writes "We have a table with sql statements.
I want to have a SP or UDF that executes each sql statment in turn and then returns the sum of each statment. I don't want to refer to the sql in the SP/UDF as I may have different requirements for sums and the program uses the sql statements elsewhere individually.

I'd want to do something like this
SELECT @cret = csql from anothertable where idfield = 'firstfield'

exec(@cret)

and save the result which will be one row

SELECT @cret = csql from anothertable where idfield = 'secondfield'

exec(@cret)

and then I want to return the results of the first select and the second select. but sellect @ntot = exec(@cret) is not a valid expression.

Any ideas?"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-11 : 08:53:19
Not sure whether this is what you wanted

SELECT @cret = csql from anothertable where idfield = 'firstfield'
SELECT @cret = @cret +' ' + csql from anothertable where idfield = 'secondfield'
SELECT @cret


Madhivanan

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

- Advertisement -