This question came up today and here is one way of doing it. It requires running xp_cmdshell so this is probably not such a good idea. The problem with functions is that you cannot just insert into any table. INSERT, UPDATE, and DELETE statements modifying
Read More...