Tuesday, 20 September 2011

COALESCE in sqlserver


DECLARE @str NVARCHAR(Max)
SELECT @str = COALESCE(@str + ';', '') + columnname FROM tablename
SELECT @str

No comments:

Post a Comment

Get all non-clustered indexes

DECLARE cIX CURSOR FOR     SELECT OBJECT_NAME(SI.Object_ID), SI.Object_ID, SI.Name, SI.Index_ID         FROM Sys.Indexes SI             ...