Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-03-01 : 09:04:29
|
| Hugo writes "Hi,I would like to declare a local variable in T-SQL and use its value as a fieldname.I tried the following code:use pubsDECLARE @lname char(30)SET @lname = 'au_fname'SELECT @lname FROM authorsI expected to see al list of firs names from authors. Why doesn't this work and is there a way of achieving this?regards,Hugo." |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2002-03-01 : 09:04:29
|
| You need to use dynamic SQL: http://www.sqlteam.com/FilterTopics.asp?TopicID=157 |
 |
|
|
|
|
|