Cover image for Sams teach yourself Transact-SQL in 21 days
Sams teach yourself Transact-SQL in 21 days
Mauer, Lowell.
Personal Author:
Second edition.
Publication Information:
Indianapolis, Ind. : Sams, [2001]

Physical Description:
xvi, 621 pages : illustrations ; 24 cm
General Note:
Includes index.
Format :


Call Number
Material Type
Home Location
Item Holds
QA76.73.S67 M338 2001 Adult Non-Fiction Central Closed Stacks

On Order



Sams Teach Yourself Transact-SQL in 21 Days, 2E will teach programmers how to develop Transact-SQL queries. There will be a focus on providing methods for improving productivity without a reducing performance. Specifically, the reader will:Learn Transact-SQL syntax Learn how to add, delete, and modifying data using Transact-SQL Understand coding standards Review variations from ANSI-standard SQL Be presented with basic server operations. Recognize performance issues with queries. This book will also include:Constructs such as CUBE, ROLLUP, CASE, and JOIN. Techniques to solve complex problems How the server uses indexes Methods to write (correctly) stored procedures and triggers. Templates of procedures and triggers (reference) Advanced Topics such as: Outer and self joins Temporary tables Sub-queries.

Author Notes

Lowell Mauer has been in data processing for more than 20 years as a programmer, instructor, and consultant. He has taught programming at Montclair State College in New Jersey and has developed and marketed several Visual Basic applications, including a SQL Server-based reservation system for a private golf course. As a manager of technical support, he has attended seminars and training sessions in several countries and is an expert in more than six computer languages. He currently is the Manager of Consulting for Cognos Corporation in New York.

David Solomon , President of Metis Technologies, LLC: I've been working in, on, and around SQL Server (in its incarnations from Sybase and Microsoft) since 1990, and I can't believe that I can still make a living in this technology. I consult and teach courses on SQL Server, and write books like this one from time to time.

When I'm not wasting my time working, I coach youth soccer enthusiastically. If you come to Troy, you'll probably find me on a soccer field, shouting and chasing kids and pretending I'm one of them.

I save the best of my time for my kids, Adam and Luke, my wife Carola, and my three cats, Lucifer, Sam, and Daisy. Right now, Lucifer is sitting in my desk chair, which leaves me standing.

Bennett McEwan is president of Geist, LLC, a company in scenic upstate New York, specializing in explaining SQL Server. The work Ben enjoys most is mentoring, where he helps programmers or database administrators through the tough spots in mission-critical applications.

Ben also teaches SQL Server training classes, writes, and designs Visual Basic client/ server applications, and consults on difficult SQL Server performance issues. You can catch him on and in the pages of Microsoft SQL Server Professional (Pinnacle Publishing).

Table of Contents

Introductionp. 1
Week 1 Working with Rows and Columnsp. 5
Day 1 Introduction to SQL and the Query Analyzerp. 7
SQL and SQL Serverp. 8
What Is T-SQL?p. 9
Retrieving Data with Query Analyzerp. 9
Introducing SQL Server 2000 Enterprise Managerp. 21
Day 2 Filtering and Sorting Datap. 29
Filtering Data with Where Clausesp. 30
Combining Conditions with Or and Andp. 38
Searching for Ranges of Values with Inequalities ([Right Angle Bracket], [Left Angle Bracket], Between)p. 41
Getting Correct Results from Date Comparisonsp. 46
Looking for Values in a List: The In Operatorp. 52
Wildcard Searches with Likep. 55
Summary of Search Conditionsp. 59
Sorting Data (Order by)p. 60
Retrieving Unique Rowsp. 63
Day 3 Working with Columnsp. 69
Column Characteristicsp. 70
Changing Result Setsp. 76
Day 4 Working with Row Aggregates and Groupingp. 99
Working with Aggregate Functionsp. 100
Grouping Datap. 113
Creating Pivot Tablesp. 127
Day 5 Joining Tablesp. 137
Understanding Joinsp. 138
Understanding More About Joinsp. 148
Writing Outer Joinsp. 162
Joining a Table to Itselfp. 167
Using Union to Merge Result Setsp. 172
Day 6 Using Subqueriesp. 181
Understanding Subqueriesp. 182
Matching a Value with Subqueriesp. 184
Checking for Membershipp. 187
Day 7 Adding, Changing, and Deleting Rowsp. 195
Creating Tablesp. 196
Deleting Tablesp. 197
Inserting Rowsp. 197
Updating Rowsp. 203
Deleting Rowsp. 206
Week 1 In Reviewp. 211
Week 2 Programming with T-SQLp. 213
Day 8 Defining Datap. 215
What Is Data Definition Language (DDL)?p. 216
Working with Tablesp. 223
Altering Tablesp. 232
Defining Constraintsp. 235
Defining Table Relationshipsp. 236
Day 9 Indexes and Performancep. 243
How SQL Server Uses Indexesp. 244
Defining and Managing Indexesp. 254
Performing Index Maintenance and Using Performance Toolsp. 266
Day 10 Views and Temporary Tablesp. 275
Using Views to Access Datap. 276
Using Temporary Tables for Storing Datap. 298
Temporary Tables Versus Viewsp. 304
Day 11 T-SQL Programming Fundamentalsp. 307
Handling Variablesp. 308
Reviewing Programming Structuresp. 313
Trapping Errors and Implementing Error Handlingp. 321
Day 12 Understanding Database Lockingp. 333
Lock Fundamentalsp. 334
Testing Lock Interactionp. 342
Understanding Lock Persistencep. 346
Day 13 Programming with Transactionsp. 367
Understanding Transaction Basicsp. 368
Controlling Transactions in Your Programsp. 373
Managing Concurrencyp. 383
Handling Long-Running Transactionsp. 386
Day 14 Using Cursorsp. 391
Defining Cursorsp. 392
Working with Cursorsp. 395
Cursor Lockingp. 408
Week 2 In Reviewp. 411
Week 3 Procedures and Triggersp. 413
Day 15 Writing and Executing Stored Proceduresp. 415
Benefits of Stored Proceduresp. 416
Writing Your First Stored Procedurep. 417
Working with Parametersp. 423
Returning Procedure Statusp. 429
Using Output Parametersp. 431
Five Ways to Communicate Between Stored Procedures and Client Programsp. 435
Day 16 Optimizing Stored Proceduresp. 439
Understanding Stored Procedure Optimizationp. 440
Using Table Variables and Temporary Tables with Proceduresp. 447
Handling Transactions in Stored Proceduresp. 452
Day 17 Debugging Stored Proceduresp. 463
Debugging Explainedp. 464
Using the T-SQL Debuggerp. 473
Day 18 Writing and Testing Triggersp. 487
Understanding Triggersp. 488
Executing Triggersp. 494
Using Trigger Resourcesp. 499
Determining When to Use Triggersp. 504
Day 19 Solving Special Trigger Problemsp. 507
Managing Referential Integrity with Triggersp. 508
Managing Special Database Actions with Triggersp. 519
Day 20 User-Defined Functions in SQLp. 531
Understanding User-Defined Functionsp. 532
Reviewing Advanced UDF Topicsp. 540
Day 21 Handling BLOBs in T-SQLp. 545
Understanding Large Data Typesp. 545
Managing BLOB Datap. 550
Week 3 In Reviewp. 559
Appendix A Answers to Quizzes and Exercisesp. 561
Indexp. 599