Introduction:
Here I will explain how to solve the problem of “invalid use of a side-effecting operator 'insert' within a function in SQL Server”.
Description:
In previous posts I explained many articles relating to solve errors in asp.net, SQL Server, IIS, etc. Now I will explain how to solve the problem of “invalid use of a side-effecting operator 'insert' within a function in SQL Server”.
Here I will explain how to solve the problem of “invalid use of a side-effecting operator 'insert' within a function in SQL Server”.
Description:
In previous posts I explained many articles relating to solve errors in asp.net, SQL Server, IIS, etc. Now I will explain how to solve the problem of “invalid use of a side-effecting operator 'insert' within a function in SQL Server”.
Generally
this problem will occur whenever we try to write insert, update and delete
queries inside of
SQL Server functions like as
shown below
CREATE FUNCTION
[dbo].[testfunction]
(
@LeadChannel VARCHAR(250),
@UserId INT
)
RETURNS INT
AS
BEGIN
DECLARE @Channel INT
Set @Channel = 0
INSERT INTO
PRESALE_LeadChannel(Source,Createdby)
VALUES(@LeadChannel,@UserId)
SELECT @Channel= @@IDENTITY
RETURN @Channel
END
|
In above function I written insert query because of that when we
call this function we will get error like “invalid use of a
side-effecting operator 'insert' within a function.”
To solve this problem we
should not use insert, update and delete quries inside of functions.
I
hope it helps you to solve your problem. Happy Coding………
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
1 comments :
you're kidding, right? That's your answer?
Note: Only a member of this blog may post a comment.