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
 General SQL Server Forums
 New to SQL Server Programming
 Select Query that matches data and column names

Author  Topic 

olamalam
Starting Member

1 Post

Posted - 2011-04-18 : 11:19:29
Dear All,

I need to write a query which brings me the data on the columns matched with column names.

For example,
id name surname age
1 John Smith 20

I need a query which brings me:
id:1;name:John;surname:Smith;age:20

Is it possible?

Thanks in advanced

edit: moved to proper forum

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-04-18 : 12:09:06
Select 'id:'+convert(varchar(50),id)+';name:'+[name]+';surname:'+surname+';age:' + convert(varchar(3),age)

from yourTable

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -