You can't do it.
Look at the documentation:
https://msdn.microsoft.com/en-us/library/aa175085%28v=sql.80%29.aspx?f=255&MSPPError=-2147217396[
^] and you will see that:
The statements in a BEGIN...END block cannot have any side effects. Function side effects are any permanent changes to the state of a resource that has a scope outside the function such as a modification to a database table. The only changes that can be made by the statements in the function are changes to objects local to the function, such as local cursors or variables. Modifications to database tables, operations on cursors that are not local to the function, sending e-mail, attempting a catalog modification, and generating a result set that is returned to the user are examples of actions that cannot be performed in a function.
You can do these in a stored procedure, (but you can't call them from a UDF either) but you cannot CREATE, ALTER, or DROP tables within a function.