The SQL odyssey continues: ListLen and ListLast
The SQL odyssey continues. Today I found myself writing a trigger for a VoIP call detail records table where some numbers came with special technical prefixes; the format was 945#5555555555… or sometimes even 123#456#5555555555
So instead of looping through the # signs with charindex, I decided to write ListLen and ListLast function to almost complete the collection.
In the trigger I had statements such as
DO STUFF
Or to always get the dialed number regardless of the prefixes I used
SET @number = dbo.ListLast(@number,’#’)
Really helpful.
Get the functions here.



