Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Erro: Invalid use of side-effecting or time-depend

Author  Topic 

ducletan
Starting Member

25 Posts

Posted - 2010-12-08 : 23:06:01
CREATE FUNCTION dbo.function1 (
@Fullname nvarchar(40),
)
RETURNS nvarchar(255)
AS
BEGIN
insert dbo.LOGUSER ([Fullname]) values ( @Fullname )
RETURN 'OK'
end

Help me

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-09 : 00:33:00
DML (insert, update, delete) Operations are not allowed inside a function. You need to use Stored procedure.
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-09 : 00:37:48
If you decide to use SP, the below is sample code for you to start with:

Create procedure sp_Test
@Fullname nvarchar(40), @RetStatus varchar(50) output
As
Begin

Insert dbo.LOGUSER ([Fullname]) values ( @Fullname )

If @@error =0
Set @RetStatus ='OK'
Else
Set @RetStatus ='Fail'
End

Go

--Execution part
Declare @MyVar varchar(50)
Exec sp_Test 'TestVal', @MyVar output
Print @MyVar

Regards,
Bohra

I am here to learn from Masters and help new bees in learning.
Go to Top of Page

ducletan
Starting Member

25 Posts

Posted - 2010-12-09 : 01:51:17
thanks
Go to Top of Page

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-09 : 03:08:00
quote:
Originally posted by ducletan

thanks



You are welcome

I am here to learn from Masters and help new bees in learning.
Go to Top of Page
   

- Advertisement -