Database Reference
In-Depth Information
Try It: Working with Stored Procedures in SQL Server
Let's create a stored procedure using SQL Server Management Studio that produces a list of the contact
details of a person in the AdventureWorks database. It requires no input and doesn't need to set a return
value.
1. Open SQL Server Management Studio, and in Connect to Server dialog select
localhost\SQL2012 as the server name; then click Connect.
2. In the Object Explorer, expand the Databases node, select the AdventureWorks
database, and click the New Query pane. Enter the following query, and click
Execute. You should see the results in Figure 6-1. Create procedure
sp_Select_All_PersonContact As select Contact.Title, Contact.FirstName,
Contact.LastName from Person.Contact
Figure 6-1. Creating a stored procedure using SQL Server Management Studio
3. To execute the stored procedure, enter the command as shown in Figure 6-2,
and click Execute. You should see the results shown in Figure 6-2.
 
Search WWH ::




Custom Search