Question: can we use dml in function?
Answer: In Micosoft SQL Server, functions cannot produce side-effects. This means you cannot modify the database state (change data available outside the function scope) within the function although you can execute SELECT DML.