SQL 2008 perhaps?
What I did actually mean was the code from the original post that wasn't working.
Although, I imagine that it was all the same, except that the SQL has now changed (back to the system tables as opposed to views - well, views behaving as tables to views really)?
My point is...