Buying Options
Transact-SQL Cookbook
Print $39.99
Add to Cart
Print+Ebook $43.99
Add to Cart
Ebook $27.99
Add to Cart
Safari Books Online
Add to Cart
What is this?
Print £30.99
Add to Cart
What is this?
Description
This cookbook contains a wealth of solutions to problems that SQL programmers face all the time. Recipes inside range from how to perform simple tasks, like importing external data, to ways of handling issues that are more complicated, like set algebra. Each recipe includes a discussion that explains the logic and concepts underlying the solution. The book covers audit logging, hierarchies, importing data, sets, statistics, temporal data, and data structures.
Full Description
Table of Contents
  1. Chapter 1 Pivot Tables

    1. Using a Pivot Table

  2. Chapter 2 Sets

    1. Introduction

    2. The Students Example

    3. Implementing Set Difference

    4. Comparing Two Sets for Equality

    5. Implementing Partial Intersection

    6. Implementing Full Intersection

    7. Classifying Subsets

    8. Summarizing Classes of Sets

    9. Aggregating Aggregates

    10. Summarizing Aggregated Classes

    11. Including Nonaggregated Columns

    12. Finding the Top N Values in a Set

    13. Reporting the Size of a Set's Complement

    14. Finding the Complement of a Set

    15. Finding the Complement of a Missing Set

    16. Finding Complements of Sets with Different Universes

    17. Comparing a Set with Its Universe

    18. Dynamic Classification System

  3. Chapter 3 Data Structures

    1. Types of Data Structures

    2. Working Example

    3. Finding Regions

    4. Reporting Region Boundaries

    5. Limiting Region Size

    6. Ranking Regions by Size

    7. Working with Sequences

    8. Working with Runs

    9. Cumulative Aggregates in Lists

    10. Implementing a Stack

    11. Implementing Queues

    12. Implementing Priority Queues

    13. Comparing Two Rows in an Array

    14. Printing Matrices and Arrays

    15. Transposing a Matrix

    16. Calculating a Matrix Trace

    17. Comparing Two Matrices for Size

    18. Adding and Subtracting Matrices

    19. Multiplying Matrices

  4. Chapter 4 Hierarchies in SQL

    1. Types of Hierarchies

    2. Creating a Permission Hierarchy

    3. Changing Individual Permissions

    4. Adding New Individual Permissions

    5. Centralizing Authorization Logic

    6. Implementing General Hierarchies

    7. Traversing Hierarchies Recursively

    8. Manipulating Hierarchies Recursively

    9. Aggregating Hierarchies

    10. Preparing Multilevel Operations

    11. Aggregating Hierarchies Revised

  5. Chapter 5 Temporal Data

    1. Introduction

    2. The Schedules Example

    3. Enforcing Granularity Rules

    4. Storing Out-of-Range Temporal Values

    5. Deriving the First and Last Dates of the Month

    6. Printing Calendars

    7. Calculating Durations

    8. Reporting Durations

    9. Querying Periods

    10. Querying Periods and Respecting Granularity

    11. Finding Available Periods

    12. Finding Common Available Periods

    13. Excluding Recurrent Events

    14. Excluding Nonrecurring Events

    15. Finding Continuous Periods

    16. Using Calendar Information with Periods

    17. Using Calendar Information with Durations

  6. Chapter 6 Audit Logging

    1. Audit Logs

    2. The Warehouse Example

    3. Row-Level Logging

    4. Reporting Log Events

    5. Generating Current Snapshots

    6. Generating Time-Restricted Snapshots

    7. Undoing Table Changes

    8. Minimizing Audit-Log Space Consumption

    9. Online Account Balancing

    10. Activity-Level Logging

    11. Partitioning Large Log Tables

    12. Server Push

  7. Chapter 7 Importing and Transforming Data

    1. Considerations When Importing Data

    2. Working Examples

    3. Importing External Data

    4. Importing Data into a Live System

    5. Importing with a Single Procedure

    6. Hiding the Import Procedure

    7. Folding Tables

    8. Pivoting Tables

    9. Joining Arrays with Tables

    10. Joining Arrays with Master Tables

    11. Joining Arrays with Multiple Master Records

    12. Extracting Master Records from Tables

    13. Generating Master Records Online

    14. Working with Duplicates

  8. Chapter 8 Statistics in SQL

    1. Statistical Concepts

    2. The Light-Bulb Factory Example

    3. Calculating a Mean

    4. Calculating a Mode

    5. Calculating a Median

    6. Calculating Standard Deviation, Variance, and Standard Error

    7. Building Confidence Intervals

    8. Calculating Correlation

    9. Exploring Patterns with Autocorrelation

    10. Using a Simple Moving Average

    11. Extending Moving Averages

  1. Appendix A The T-Distribution Table

  2. Colophon

View Full Table of Contents
Product Details
Title:
Transact-SQL Cookbook
By:
Ales Spetic, Jonathan Gennick
Publisher:
O'Reilly Media
Formats:
  • Print
  • Ebook
  • Safari Books Online
Print Release:
March 2002
Ebook Release:
February 2009
Pages:
304
Print ISBN:
978-1-56592-756-8
| ISBN 10:
1-56592-756-7
Ebook ISBN:
978-0-596-10363-7
| ISBN 10:
0-596-10363-8
Customer Reviews
About the Authors
  1. Ales Spetic

    Ales Spetic, an independent consultant specializing in the design and implementation of financial applications, has been programming in SQL for the past six years. He has a MBA California State University, Hayward.

    View Ales Spetic's full profile page.

  2. Jonathan Gennick

    Jonathan Gennick is an O'Reilly & Associates editor specializing in database and programming titles. Prior to joining O'Reilly, Jonathan amassed some 17 years of programming and database management experience. During the latter part of his career he specialized in relational database programming, and more recently in database management. Jonathan got his start with relational database systems in 1990, first working with Ingres, and later with Digital's Rdb software. During that period he developed a fondness for SQL, and for the challenge of applying SQL creatively in ways that leveraged it's set-oriented capabilities. In 1994 Jonathan made the leap to Oracle, and is now often found writing about it. Recent projects include Oracle SQL*Loader (O'Reilly & Associates, 2001); Oracle SQL*Plus Pocket Reference (O'Reilly & Associates, 2000); Oracle SQL*Plus: The Definitive Guide (O'Reilly & Associates, 1999); More recently, Jonathan has made forays into other database products, coauthoring Transact-SQL Cookbook (O'Reilly & Associates, 2002) and editing Practical PostgreSQL (O'Reilly & Associates, 2002). Jonathan is certified as an Oracle DBA and is a member of MENSA and the Oracle Technology Network. He holds a Bachelor of Arts degree in Information and Computer Science, with a Business Administration minor, from Andrews University in Berrien Springs, Michigan. Jonathan currently resides in Munising, Michigan with his wife Donna and their two children: Jenny and Jeff. Jonathan may be contacted by email at jonathan@gennick.com, and you can learn more about him personally by visiting his website at http://gennick.com.

    View Jonathan Gennick's full profile page.

Colophon

Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The animal on the cover of Transact-SQL Cookbook is a tree swift. Swifts are small, swallow-like birds related to hummingbirds. They are found all over the world, especially in the tropics. There are many different species of swifts that are specific to certain regions.

Swifts range from 3.5 to 9 inches in length. Their powerful, streamlined bodies have long wings; small, weak legs; and small feet. Swifts perch on vertical surfaces, but, due to their weak legs, once they perch, they have a difficult time returning to flight. Because of this, swifts do nearly everything on the wing, including feeding, drinking, bathing, courting, and sometimes mating. Their strong wings also make them rapid fliers.

Jeffrey Holcomb was the production editor and proofreader for Transact-SQL Cookbook . Tatiana Apandi Diaz was the copyeditor. Linley Dolby, Leanne Soylemez, and Claire Cloutier provided quality control. Phil Dangler, Leanne Soylemez, and David Chu provided production assistance. Johnna VanHoose Dinse wrote the index. Ellie Volckhausen designed the cover of this book, based on a series design by Edie Freedman. The cover image is a 19th-century engraving from the Dover Pictorial Archive. Emma Colby produced the cover layout with QuarkXPress 4.1 using Adobe's ITC Garamond font.

David Futato designed the interior layout. Neil Walls converted the files from Microsoft Word to FrameMaker 5.5.6 using tools created by Mike Sierra. The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont's TheSans Mono Condensed. The illustrations that appear in the book were produced by Robert Romano and Jessamyn Read using Macromedia FreeHand 9 and Adobe Photoshop 6. The tip and warning icons were drawn by Christopher Bing. This colophon was written by Linley Dolby.

  • Book cover of Transact-SQL Cookbook