Thursday, July 16, 2020

HOW TO CREATE A FUNCTION AND USE IT INTO THE STORED PROCEDURE IN SQL SERVER

The function is a sql statements that returns a value. So here,we will create one scalar function and use it into the Stored Procedure in sql server. The process is as follows:

Step 1: Open the database that you created in your system.

Step 2: Click on the Programmability > Functions then you will see the Scalar-valued Functions option and right click on it then you will see an option i.e. New Scalar-valued Function. Click on it. Please see the below screenshot.



After click on the New Scalar-valued Function, you will see new window on where you can write your functions or sql statements.



Here, we will create a function to get the employee salary by passing employee id into the function. Please see the below screenshots.


Now, we will use the above function into the stored procedure.


So, here we have successfully created a new stored procedure and used above function into it by pass employee id. So, now we will see that how we will execute our stored procedure and get salary from the above created function. Please see the below screenshot:



                       - - - - - - Cheers, Happy to Help! - - - - - - 

No comments:

Post a Comment

DIFFERENCE BETWEEN CHAR AND VARCHAR IN SQL SERVER

CHAR:  The  CHAR datatype is a fixed length data type in sql server. It is used to store fixed length type of string data or character strin...