• Do you know how can I do the same in sql server 2005?

    This functions properly only in sql server 2008 and 2012.