Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

SQL Server - Invalid Use of a Side-Effecting Operator 'insert' within a Function

Sep 3, 2013
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”.

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.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

Time for Action said...

you're kidding, right? That's your answer?

Give your Valuable Comments

Other Related Posts

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.