How to create and use Function

Santosh0683
Posted by Santosh0683 under Sql Server category on | Views : 1693
Sql server Function With Arguments
here it is simple example how to use function n sql server.
1.Create function
2.use this function where required.

CREATE FUNCTION AddTwoNumber(@Num1 Decimal(6,2),
@Num2 Decimal(6,2))
RETURNS Decimal(6,2)
BEGIN
DECLARE @Result Decimal(6,2)
SET @Result = @Num1 + @Num2
RETURN @Result
END;
GO


=========
RESULTS
=========
PRINT MyDbName.dbo.AddTwoNumber(100, 200);

Comments or Responses

Posted by: Shankul2784 on: 8/5/2010 Level:Bronze | Status: [Member]

I will suggest you to use the following link, i hope it will help you a lot.

http://www.sqlteam.com/article/user-defined-functions

Login to post response