I want to pass the result of a query in a variable in sql server 2005 procedure.
Please guide.
How to pass value of a query in a variable?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rekha SinghRank #1,571 · 1K reputationPosted Jan 5, 2010, 3:20 AM EST
declare @var as nvarchar(50)
set @var = ( select name from test where id ='1')
print @var
@var is a variable which will have the query result
*********************************************
Pls mark Accepted if u find it helpful