Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic SQL

Status
Not open for further replies.

lllyxer

Programmer
Nov 22, 2006
22
US
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
 
Please re-post this in one of the SQL forums. You'll receive more hits there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top