I need a help with the following scenario.
I have two dynamic SQL like this:
DECLARE @sSQL_ID varchar(1000)
SELECT @sSQL_ID= 'SELECT ID FROM Store WHERE StoreLocation='New York'
DECLARE sSQL varchar(1000)
SELECT @sSQL = 'SELECT * FROM City WHERE StoreID = @sSQL
Of course the second statement (the one in bold) is incorrect.
What I need to do is to pass a value returned from first dynamic sql(@sSQL_ID) into second(@sSQL), so it will read something like this SELECT @sSQL = 'SELECT * FROM City WHERE StoreID = 10
Thank you
I have two dynamic SQL like this:
DECLARE @sSQL_ID varchar(1000)
SELECT @sSQL_ID= 'SELECT ID FROM Store WHERE StoreLocation='New York'
DECLARE sSQL varchar(1000)
SELECT @sSQL = 'SELECT * FROM City WHERE StoreID = @sSQL
Of course the second statement (the one in bold) is incorrect.
What I need to do is to pass a value returned from first dynamic sql(@sSQL_ID) into second(@sSQL), so it will read something like this SELECT @sSQL = 'SELECT * FROM City WHERE StoreID = 10
Thank you