johnscott76
MIS
Hopefully this is a simple question and I'm just not seeing the answer sitting in front of my face...
I'm trying to return the results of a dynamic query to the batch, and so far I've had trouble.
Here's an excerpt:
Any ideas?
I'm trying to return the results of a dynamic query to the batch, and so far I've had trouble.
Here's an excerpt:
Code:
Declare @QueryPending nvarchar(4000)
Set @QueryPending =
N' Select *
From STop_' + @dbDataStream + '.dbo.AGTXREF
Where CUST# = ' + Convert(varchar(8), @CUST#) + '
And AGTSTS = ''C''
And AGSSTS = ''NA''
'
-- This next line is what I'd like to accomplish, in some form or another
If Exists ( Execute sp_executesql @QueryPending ) Set @Status = 'P'
Any ideas?