The built-in string handling functions in t-sql are all well and good, but there really aren’t any graceful ways of handling lists. As any CF developer that’s been around a while knows, lists are pretty commonplace in practice, and there are times when it makes more sense (or you’re required) to do list handling at the db level rather than at the front end.

The following six SQL Server udf’s provide equivalent functionality to the ColdFusion list functions listfirst, listgetat, listsetat, listlast, listfind, and listcontains. The only thing that differs from their CF counterparts (and a minor one at that) is that they require you to pass a single delimiter, not a set of possible delimiters as in CF.

UPDATE 2/10/2011: now includes a listfind function as well.

UPDATE 10/16/2011: now includes a listsetat function courtesy of Bud Schneegan.

UPDATE 5/6/2012: now includes a listcontains function by request.