Session 9–T-SQL and SQL Query Analyzer.......................................................95
Learning about T-SQL and SQL Query Analyzer ................................................95
Creating, Altering, and Dropping Databases with T-SQL ...................................98
Creating databases .......................................................................................98
Altering databases .......................................................................................99
Dropping databases ....................................................................................100
Creating, Altering, and Dropping Tables with T-SQL.......................................100
Creating tables ..........................................................................................100
Altering tables...........................................................................................101
Deleting tables...........................................................................................102
Getting Information about Your SQL Server...................................................102
Working with the Query Analyzer Templates and the Object Browser..............103
Session 10–Programming with T-SQL .........................................................107
Declaring and Using T-SQL Variables .............................................................107
Implicit conversion.....................................................................................109
Explicit conversion .....................................................................................110
Using Control-of-Flow Statements .................................................................111
Exploring T-SQL Operators ..........................................................................113
Arithmetic operators...................................................................................114
Comparison operators .................................................................................114
Logical operators........................................................................................115
The assignment operator .............................................................................116
The string concatenation operator................................................................116
Unary operators .........................................................................................116
Operator precedence ...................................................................................117
Working with Aggregate Functions ...............................................................118
Running Subqueries .....................................................................................118
Using the CASE Function ..............................................................................119
Part III—Saturday Afternoon ..................................................124
Session 11–Creating and Using Stored Procedures .......................................125
Creating Stored Procedures ...........................................................................125
Commenting Transact-SQL Code ....................................................................128
Error Handling ............................................................................................129
Using Different Types of Stored Procedures...................................................132
Temporary stored procedures .......................................................................132
Nested and recursive stored procedures.........................................................133
System stored procedures............................................................................134
Renaming and Dropping a Stored Procedure ..................................................134
Session 12–Trigger Happy ..........................................................................137
Introducing Triggers.....................................................................................137
AFTER triggers ...........................................................................................139
INSTEAD OF triggers ...................................................................................141
Contents xix
014840-9 FM.F 8/28/01 12:51 PM Page xix