Hello,
there is trick in your code - last char from waitresource is cutted of. I work for a while with it, and it seems that waitresource from sysprocesses always have extra char at the end.
For more clarity I do this:
select @colon1index = charindex (':', @waitresource)
if (@colon1index < 0)
return
select @colon2index = charindex (':', @waitresource, @colon1index+1)
if (@colon2index <= 0)
return
select
@dbid = substring(@waitresource, 1, @colon1index - 1),
@fileid = substring(@waitresource, @colon1index + 1, @colon2index - @colon1index - 1),
@pageid = substring(@waitresource, @colon2index + 1, len(@waitresource) - @colon2index - 1)