/* _A_dd to _C_omma delimited _L_ist - simplified version of AddToList Adds an element (nvarchar) to the end of a comma delimited list (nvarchar) */ ALTER FUNCTION dbo.fnACL (@List nvarchar(4000), @New nvarchar(4000)) RETURNS nvarchar(4000) AS BEGIN --Treat ''s as NULLs SELECT @List = NULLIF(@List, ''), @New = NULLIF(@New, '') --first try returning the concatened string, if null then try just the list, if it too is null, just the new element RETURN COALESCE(@List + ',' + @New, @List, @New) END
Never been to CodeSnippets before?
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 (or not, you can keep them private!)
UDF to Add items to a comma delimited list (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails