STORED PROCEDURE AND FUNCTION

Stored Procedure:-

  • Stored procedures return a zero or N value.
Original Table

Example:-

Create procedure output

AS

Begin

UPDATE [dbo].[tbl]

SET [name]=’ANKITA’

WHERE id=1

End

Output:-

exec output

select * from [dbo].[tbl]

Updated Table

Function:

  • The function can return a scalar value.

Example:-

create function fun()

returns money

AS

Begin

RETURN(SELECT SUM([salary])

FROM [dbo].[tbl])

End

Output:-

USE [DB]

GO

SELECT [dbo].[fun]() as Total

GO

Result

If you are newer to database learning -SQL Server recommended is the following must-watch video: -

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Zoom API Integration in UiPath

What is a hackathon?

HackZurich 2019 from above

Deploying High Availability Architecture with AWS CLI

Decorator design pattern: minimal and practical example

cTrader vs MT4: Decisive Factors in Choosing the Best Trading Platform

ctrader vs mt4

Car Vehicle Base on Arduino Nano

Git commands data scientists use on a day-to-day basis

Web Crawler

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vaishali Goilkar

Vaishali Goilkar

More from Medium

The Importance of Generic Programming

How to read an Excel File in Java Selenium projects

BASICS OF PYTEST

oops in java: