I have a dynamic SQL statement to insert data into a memory table from a source table. The problem is, one of my variables, when run, evaluates out to a name of a column in the table I'm selecting from. I need it to be the column name, not whats in the column for my result.

The cursor @qa is holding the data item I want to include in the insert.

set @sql = 'INSERT INTO #MemoryTable (First_Name, Last_Name, Address_Line_1, Address_Line_2, City, State, ZipCode, Addressflag, HomePhone, eMail, emailflag, QuestionKey)

SEELECT FirstName, LastName, Address, Apartment, City, State, ZipCode, ''H'', PrimaryPhone, emailAddress, ''H'', ' + @qa + '
FROM SourceTable
WHERE ' + @qa + ' <> ''No'''

So, instead of getting the column literal, I get the data item in the source table from that column. Is there any way to force the SELECT not to evaluate out the variable?

Ok, forget it, I figured it out.. quote it as a string.. duh.. sorry, when you look at a problem too long, the obvious escapes you.. :)