I am trying to implement a nested query with a dynamic query.
I have tried something like this:
SET @str = 'Select @GRP= ' + @Field +'
from Hist_Tab
Where TerminalID in (Select id from newtab where lease='+@Lease +')';
exec sp_executesql @query=@str,
@params= N' @GRP Numeric(15,2) Ouptut',
@GRP=@GRP Output
but it seems I can't implement the nested queries this way ...
Any suggestion??
Thanks in advance
@strcontains after its assigned