If this is not the right forum please let me know and move it for me.
I've just got a bunch of inserts like this toward the end of my scalar function:
INSERT INTO [Raptor].[dbo].[UserRole]
([RoleId]
,[UserId])
VALUES
(3
,@NewUserID)
INSERT INTO [Raptor].[dbo].[UserRole]
([RoleId]
,[UserId])
VALUES
(5
,@NewUserID)
Best Answer
In T-SQL, you cannot modify any data in a function. There is no straightforward way around it. There are some obscure hacks, but I would not use them. Use a stored procedure.
The hack, quoting from Erland Sommarskog: