Thu 29 Dec 2011

Code

Tags:
Categories :
Comments (1)

Comments

12/29/2014 | samwids  United States
Comma separated column name - sql server

Select TABLE_SCHEMA, TABLE_NAME
    , Stuff(
        (
        Select ', ' + C.COLUMN_NAME
        From INFORMATION_SCHEMA.COLUMNS As C
        Where C.TABLE_SCHEMA = T.TABLE_SCHEMA
            And C.TABLE_NAME = T.TABLE_NAME
        Order By C.ORDINAL_POSITION
        For Xml Path('')
        ), 1, 2, '') As Columns
From INFORMATION_SCHEMA.TABLES As T
where T.TABLE_NAME = 'Logs'


Add Comment Post comment

 
 
 
   Country flag

Loading

Captcha





Ads