CREATE FUNCTION UDF_DMLOperationTest()
RETURNS INT
AS
BEGIN
INSERT INTO LocationTable VALUES(167,'XXX') -- we are trying to do DML operation inside a function
RETURN 1
END
Above CREATE FUNCTION code gives this error:
Invalid use of a side-effecting operator 'INSERT' within a function. NOTE: This is one of rule we all should know.....
One more important thing is we can
apply DML operation on table variable inside a function