DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Add To List Function
--Adds an element (nvarchar) to the end of a list (nvarchar), after first inserting a delimiter (nvarchar) ALTER FUNCTION dbo.fnAddToList (@List nvarchar(4000), @New nvarchar(4000), @Del nvarchar(10)) RETURNS nvarchar(4000) AS BEGIN --Treat ''s as NULLs SELECT @List = NULLIF(@List, ''), @Del = NULLIF(@Del, ''), @New = NULLIF(@New, '') --First try the concatened string, if null then just the list, --if it too is null, just the new element RETURN COALESCE(@List + @Del + @New, @List, @New) END
Oskar Austegard <a href="http://mo.notono.us">http://mo.notono.us</a>





