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 |
|
eddie
Starting Member
45 Posts |
Posted - 2002-06-14 : 18:20:25
|
| How can I stuff a column name in a variable and then use that variable name in a select statement?Ex.Declare @test char(20)set @test='columnname'Select @test from tablenameCurrently, this just returns is at a string for every row in the table instead of the values in the actual column.Eddie |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-06-14 : 19:10:34
|
| You need to use Dynamic SQL to accomplish this. Read these articles to get started:[url]http://www.sqlteam.com/item.asp?ItemID=4599[/url][url]http://www.sqlteam.com/item.asp?ItemID=4619[/url] |
 |
|
|
|
|
|