I prefer Waterducks methods as it is independent of any system tables. I'm always nervous to use tables like spt_values in production code as its implementation may change in future.Only change i would have done will be to change the last filter as below

I prefer Waterducks methods as it is independent of any system tables. I'm always nervous to use tables like spt_values in production code as its implementation may change in future.Only change i would have done will be to change the last filter as below