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
 joining columns

Author  Topic 

paulholzweber
Starting Member

4 Posts

Posted - 2009-02-10 : 10:48:07
Hi,

I want to do something like that:

select [column1] + '_' + [column2] + '_' + [column3]
from database

where I have strings in the columns.
The bad part is, I have hundreds of columns and I don't know ther names (generated with dynamic pivot). Is there any way to get around naming them one by one?

Thanks
Paul

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-10 : 10:50:46
use INFORMATION_SCHEMA.COLUMNS view to get column names from table

SELECT column_Name FROM INFORMATION_SCHEMA.COLUMNS WHERE Table_Name= 'your table'
Go to Top of Page

paulholzweber
Starting Member

4 Posts

Posted - 2009-02-11 : 02:42:04
Hi,

thanks for the answer!
Well... but then I have a table with the colum names and I still need somehow a loop to join them, no?
Do you have any idea how to do that?

Thanks
Paul
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-11 : 03:10:10
do you mean you have column name as values themselves in your table?
Go to Top of Page
   

- Advertisement -