From the course: SQL Server 2008 Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Creating stored procedures

Creating stored procedures - SQL Server Tutorial

From the course: SQL Server 2008 Essential Training

Start my 1-month free trial

Creating stored procedures

The process of creating a stored procedure is quite similar to that of doing a function, or indeed of defining any procedure, function, or method in any other programming language. We're going to name it. We have to give it a name. We're going to define any parameters that it takes. We're going to actually describe what it does, which in our case will be run either a single SQL statement or even batches of T-SQL. And then return any values, describe what it is that gets sent back. So how do we do that? Well, luckily, SQL Server Management Studio has some helpers for us. If I actually drill down into the database in which I want to create my stored procedure, I'll use AdventureWorksLT, I'll open up the Programmability section and we see that we have the Stored Procedures folder right beside the Functions folder. I'll open that guy up. I'll right-click the Stored Procedures folder and say New Stored Procedure. Again, we get a lot of boilerplate code. Just to make things clearer, I could…

Contents