Rob Gonda's Blog

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

 

IF dbo.ListLen(@number,’#’) = 3
 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.

Related Blog Entries

TrackBacks
There are no trackbacks for this entry.

Trackback URL for this entry:
http://www.robgonda.com/blog/trackback.cfm?7D8DBEA7-3048-7431-E4FCF23ABC917D7C

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
This blog is running version 5.9.003. Contact Blog Owner