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

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...