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 |
karthick.amace
Starting Member
23 Posts |
Posted - 2010-07-23 : 22:12:47
|
Hi brothersI want to know the datatype which is used to store the column name of table. Because I want to use that column name in my Update statementPlz help me and suggest me to do..sampleDeclare @colname ?????Set @colname=(SELECT c.name FROM sys.tables AS tINNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_IDWHERE t.name='Acomp' and c.name=1)Update AcompSet @colname=5Where empid=101my column will be like numbers eg.,[1],[2],[3]...wherevr my input values and colname mayches I want to update the valuethis is the requirementI tried this, unfortunately is not workedDECLARE @temp sysnameSET @temp=(SELECT c.name FROM sys.tables AS tINNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_IDWHERE t.name='Acomp' and c.name=1)update ACompset @temp=5where empid=101I thnk it taking @temp as some temp variable not as column...Plz let me know is that possible...? |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2010-07-23 : 22:59:12
|
Please do not cross post:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=147733 |
 |
|
|
|
|