• I think it is better to write CLR function for it,if you are using sql server 2005 or 2008