From the course: Complete Guide to Advanced SQL Server

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Stored procedure output parameters

Stored procedure output parameters - SQL Server Tutorial

From the course: Complete Guide to Advanced SQL Server

Stored procedure output parameters

SQL Server Stored procedures can pass information back through the use of output parameters. This is mostly used when a front end application is used to interface with the database server, and it allows the stored procedure to communicate success messages or other important status updates to the application. Since we're not in an environment where we're actually writing a custom application for the database, output parameters are a little bit tricky to demonstrate, but we can write a small example to show how they work. When you create a stored procedure that includes an output parameter, you name it just like you would with input parameters. I'm going to create a simple procedure called uspSimpleProcedure, and it's going to have an output parameter called OutputMessage. We still need to give it a data type. So I'll give this one the nvarchar 200 data type. And then we need to make sure that we include the keyword "OUTPUT" at the end. This tells SQL Server that the value of this…

Contents