Advertisement

03.15.2007 at 12:42PM PDT, ID: 22452516
[x]
Attachment Details

Dynamic Sql Query variable assignment

Asked by application1973 in SQL Server 2005

Tags: sql, query, variable, dynamic

if i have a dynamic sql query something like this

set @strsql = 'select @somevar = somecolumn from ' + @tablename + 'where condition '
exec @strsql
it does not populate the @somevar variable. I have also tried
set @strsql = 'select ' + @somevar ' +  = somecolumn from ' + @tablename + 'where condition '
exec @strsql

How can i get the desired column value into this variable??
Any help will be appreciated.

Depp

Start Free Trial
 
 
[+][-]03.15.2007 at 01:57PM PDT, ID: 18730489

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.21.2007 at 07:13PM PDT, ID: 18768817

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.22.2007 at 02:05AM PDT, ID: 18769826

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.22.2007 at 06:56AM PDT, ID: 18771197

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.22.2007 at 07:03AM PDT, ID: 18771260

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: sql, query, variable, dynamic
Sign Up Now!
Solution Provided By: Nightman
Participating Experts: 1
Solution Grade: B
 
 
[+][-]03.26.2007 at 08:50AM PDT, ID: 18793685

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32