Monday 14 December 2015

Gett all column names of table Target_Table with comma separated (,) by commas



DECLARE @SQL    nvarchar(4000) = ''
SELECT @SQL += '['+COLUMN_NAME+']' + ', ' FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Employee'

select SUBSTRING(@SQL,0,len(@SQL))


result-

[EmployeeID], [OldID], [Contract_Type], [EmployeeCode]

No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...