Wiley.com
Print this page Share

Mastering Microsoft SQL Server 2005

ISBN: 978-0-7821-4380-5
Paperback
1056 pages
March 2006
Mastering Microsoft SQL Server 2005 (0782143806) cover image
This title is out-of-print and not currently available for purchase from this site.

Do you think you've discovered an error in this book? Please check the list of errata below to see if we've already addressed the error. If not, please submit the error via our Errata Form. We will attempt to verify your error; if you're right, we will post a correction below.

ChapterPageDetailsDatePrint Run
6 148 Mislabeled Table on Pg. 148

Chapter 6, page 148, has a mislabeled table: "HumanResources.Employee.DepartmentID" should be changed to "HumanResources.Employee.Employee ID"

3-26-2007
395 Procedure Correction
It appears that the method described was modified in the Production Edition and the Stored Procedure Assisted Editor is not part of the final released edition.  The actual procedure should be as described:
 

  1. In Object Explorer, connect to an instance of SQL Server 2005 Database Engine and then expand that instance.
  2. Expand Databases, expand the database in which the stored procedure belongs, and then expand Programmability.
  3. Right-click Stored Procedures, and then click New Stored Procedure.
  4. On the Query menu, click Specify Values for Template Parameters.
  5. In the Specify Values for Template Parameters dialog box, the Value column contains suggested values for the parameters. Accept the values or replace them with new values, and then click OK.
  6. In the query editor, replace the SELECT statement with the statements for your procedure.
  7. To test the syntax, on the Query menu, click Parse.
  8. To create the stored procedure, on the Query menu, click Execute.
  9. To save the script, on the File menu, click Save. Accept the file name or replace it with a new name, and then click Save.

EXAMPLE:

  1. In Object Explorer, connect to an instance of SQL Server 2005 Database Engine and then expand that instance.
  2. Expand Databases, expand the AdventureWorks database, and then expand Programmability.
  3. Right-click Stored Procedures, and then click New Stored Procedure.
  4. On the Query menu, click Specify Values for Template Parameters.
  5. In the Specify Values for Template Parameters dialog box, enter the following values for the parameters shown.

  6. Parameter Value
    Author Your name
    Create Date Today's date
    Description Returns employee data.
    Procedure_name HumanResources.uspGetEmployees
    @Param1 @LastName
    @Datatype_For_Param1 nvarchar(50)
    Default_Value_For_Param1 NULL
    @Param2 @FirstName
    @Datatype_For_Param2 nvarchar(50)
    Default_Value_For_Param2 NULL

  7. Click OK.
  8. In the query editor, replace the SELECT statement with the following statement:

  9. SELECT FirstName, LastName, JobTitle, Department
    FROM HumanResources.vEmployeeDepartment
    WHERE FirstName = @FirstName AND LastName = @LastName;

  10. To test the syntax, on the Query menu, click Parse. If an error message is returned, compare the statements with the information above and correct as needed.
  11. To create the stored procedure, on the Query menu, click Execute.
  12. To save the script, on the File menu, click Save. Enter a new file name, and then click Save.
  13. To run the stored procedure, on the toolbar, click New Query.
  14. In the query window, enter the following statements:

  15. USE AdventureWorks;
    GO
    EXECUTE HumanResources.uspGetEmployees @FirstName = N'Diane', @LastName = N'Margheim';
    GO

  16. On the Query menu, click Execute.
Back to Top