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.
| Author |
Topic |
|
ducletan
Starting Member
25 Posts |
Posted - 2010-12-08 : 23:06:01
|
| CREATE FUNCTION dbo.function1 (@Fullname nvarchar(40),)RETURNS nvarchar(255)ASBEGIN insert dbo.LOGUSER ([Fullname]) values ( @Fullname ) RETURN 'OK'endHelp 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. |
 |
|
|
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 AsBegin Insert dbo.LOGUSER ([Fullname]) values ( @Fullname ) If @@error =0 Set @RetStatus ='OK' Else Set @RetStatus ='Fail'EndGo--Execution partDeclare @MyVar varchar(50)Exec sp_Test 'TestVal', @MyVar outputPrint @MyVarRegards,BohraI am here to learn from Masters and help new bees in learning. |
 |
|
|
ducletan
Starting Member
25 Posts |
Posted - 2010-12-09 : 01:51:17
|
| thanks |
 |
|
|
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. |
 |
|
|
|
|
|