In a stored procedure I'm constructing dynamic SQL which is available in a variable like below:
DECLARE @SqlQry VARCHAR(max)
SELECT @SqlQry = @SQL --@SQL has dynamic SQL already.
I can execute this SQL statement like this:
exec (@SqlQry);
My question is how to select and returned results of this execution. I want to return these results just like a normal select statement. Please guide.