Stored Procedures Archives

Build Dynamic SQL in a Stored Procedure

Dynamic SQL

After reading this article you will understand the basics of dynamic SQL; how to build statements based on variable values, and how to execute those constructed statements using sp_executesql and EXECUTE() from within a stored procedure. All the examples for this lesson are based on Microsoft SQL Server Management Studio and the sample databases AdventureWorks […]

Continue reading

Using the WHILE Statement in Stored Procedures

After reading this article you will understand the basics of using the WHILE statement to write a loop within a stored procedure. All the examples for this lesson are based on Microsoft SQL Server Management Studio and the sample databases AdventureWorks and WideWorldImporters.  You can get started using these free tools with my Guide Getting Started […]

Continue reading

Use IF…ELSE Statements to Program a Stored Procedure

After reading this article you will understand the basics of programming a stored procedure using IF…ELSE statements; most importantly how keywords, such as BEGIN, END, IF and ELSE affect the order of execution within your stored procedures. All the examples for this lesson are based on Microsoft SQL Server Management Studio and the sample databases […]

Continue reading

Introduction to Stored Procedures for SQLServer

Stored Procedures

After reading this article you will understand the benefits of stored procedures and how to create and execute them. All the examples for this lesson are based on Microsoft SQL Server Management Studio and the sample databases AdventureWorks and WideWorldImporters.  You can get started using these free tools using my guide Getting Started Using SQL Server. […]

Continue reading
4

Learn about Stored Procedures

What is a stored procedure

What is a Stored Procedure? A stored procedure is a group of one or more database statements stored in the database’s data dictionary and called from either a remote program, another stored procedure, or the command line.  Stored procedure are commonly called SPROCS, or SP’s.  Stored procedure features and command syntax are specific to the […]

Continue reading