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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to assign value as column name

Author  Topic 

VipinMitta
Starting Member

12 Posts

Posted - 2010-03-12 : 02:56:22
Dear experts,

i want to assign value of column as other column name

suppose i have one table


create table a(id int identity, b_name varchar(100), create_time datetime )

insert into a
values('abc',getdate())

select * from a

result is

id b_name create_time
1 , 'abc' , '12/03/2010'


but i want

id name_on_12/03/2010 create_time
1 , 'abc' , '12/03/2010'



is there any solution for this please let me know

thanx in advance




webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-03-12 : 03:02:31
search for dynamic sql.
without it is not possible.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

namman
Constraint Violating Yak Guru

285 Posts

Posted - 2010-03-12 : 22:31:45
what you want for the column name if there are more than 1 row

id b_name create_time
1 , 'abc' , '12/03/2010'
2 , 'def' , '5/5/2010'


what you want for red column

id name_on_ create_time
1 , 'abc' , '12/03/2010'
2 , 'def' , '5/5/2010'
Go to Top of Page
   

- Advertisement -