Get CSV list of table columns in SQL Server.

--
-- Get a CSV list of columns in a table
--

declare @tablename as sysname = 'TABLE_NAME';

select replace(reverse(stuff(reverse((select   name + ',' as [data()]
                                      from     sys.columns
                                      where    object_name(object_id) = @tablename
                                      order by column_id
                                      for      xml path (''))), 1, 1, '')), ' ', '');