How to get row column values as row headers in sql server

DECLARE @PivotColumnHeaders VARCHAR(MAX)
SELECT @PivotColumnHeaders = COALESCE(@PivotColumnHeaders + ',[' + cast(A.FieldName as varchar) + ']','[' + cast(A.FieldName as varchar)+ ']')
FROM dbo.tablename A -- where ID =5
print @PivotColumnHeaders


Popular posts from this blog

List of special Characters in HTML

Get Random alphanumeric number with specific length using SQL Server