2013-01-27

TSQL Comma Separated List

Howdy! I ran across this TSQL snippet that renders a column as a comma delimited list (see this):

DECLARE @TeamInfo varchar(max)

SELECT @TeamInfo = COALESCE(@TeamInfo + ', ', '') + FirstName
FROM TeamInfo
WHERE TeamID = @TeamID


I've run across jQuery components that prefer these lists, and this is a great way to build them.


Steve

No comments:

Post a Comment