return values from EXEC(string) - 12-17-2004 , 11:36 AM
Firstly, apologies if this it the wrong place to ask!
I have a stored procedure which builds some SQL in an nvarchar. I can, of
course execute this SQL with EXEC(@mySQL), but how do I access the recordset
that is returned *while still within the stored procedure*?
Basically the SQL returns a single value every time, but based on wildly
varying FROM and WHERE statements (hence why I can't use CASE statements).
I'd like to do something like @myvalue = EXEC(@mySQL), but of course this
Any help would be greatly appreciated.
Re: return values from EXEC(string) - 12-17-2004 , 11:45 AM
(Reverse address to reply.)
"Jo Inferis" <jo (AT) inferis (DOT) NOSPAM.gotadsl.co.uk> wrote
RE: return values from EXEC(string) - 12-17-2004 , 11:47 AM
Use SP_EXECUTESQL instead.
declare @i int
declare @sql nvarchar(4000)
set @sql = N'select @i = count(*) from dbo.orders where orderdate >
''19960101'' and orderdate < ''19970101'''
execute sp_executesql @sql, N'@i int output', @i = @i output
"Jo Inferis" wrote: