Transact-SQL Cookbook: Help for Database Programmers

This unique cookbook contains a wealth of solutions to problems that SQL programmers face all the time. The 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. Authors Ales Spetic and Jonathan Gennick, two authorities with extensive database and SQL programming experience, include a discussion with each recipe to explain the logic and concepts underlying the solution.SQL (Structured Query Language) is the closest thing to a standard query language that currently exists, and Transact-SQL -- a full-featured programming language that dramatically extends the power of SQL -- is the procedural language of choice for both Microsoft SQL Server and Sybase SQL Server systems. The Transact-SQL Cookbook is designed so you can use the recipes directly, as a source of ideas, or as a way to learn a little more about SQL and what you can do with it. Topics covered include:

  • Audit logging. In addition to recipes for implementing an audit log, this chapter also includes recipes for: improving performance where large log tables are involved; supporting multiple-languages; and simulating server push.
  • Hierarchies. Recipes show you how to manipulate hierarchical data using Transact-SQL.
  • Importing data. This chapter introduces concepts like normalization and recipes useful for working with imported data tables.
  • Sets. Recipes demonstrate different operations, such as how to find common elements, summarize the data in a set, and find the element in a set that represents an extreme.
  • Statistics. This chapter's recipes show you how to effectively use SQL for common statistical operations from means and standard deviations to weighted moving averages.
  • Temporal data. Recipes demonstrate how to construct queries against time-based data.
  • Data Structures. This chapter shows how to manipulate data structures like stacks, queues, matrices, and arrays.
With an abundance of recipes to help you get your job done more efficiently, the Transact-SQL Cookbook is sure to become an essential part of your library.
1100303125
Transact-SQL Cookbook: Help for Database Programmers

This unique cookbook contains a wealth of solutions to problems that SQL programmers face all the time. The 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. Authors Ales Spetic and Jonathan Gennick, two authorities with extensive database and SQL programming experience, include a discussion with each recipe to explain the logic and concepts underlying the solution.SQL (Structured Query Language) is the closest thing to a standard query language that currently exists, and Transact-SQL -- a full-featured programming language that dramatically extends the power of SQL -- is the procedural language of choice for both Microsoft SQL Server and Sybase SQL Server systems. The Transact-SQL Cookbook is designed so you can use the recipes directly, as a source of ideas, or as a way to learn a little more about SQL and what you can do with it. Topics covered include:

  • Audit logging. In addition to recipes for implementing an audit log, this chapter also includes recipes for: improving performance where large log tables are involved; supporting multiple-languages; and simulating server push.
  • Hierarchies. Recipes show you how to manipulate hierarchical data using Transact-SQL.
  • Importing data. This chapter introduces concepts like normalization and recipes useful for working with imported data tables.
  • Sets. Recipes demonstrate different operations, such as how to find common elements, summarize the data in a set, and find the element in a set that represents an extreme.
  • Statistics. This chapter's recipes show you how to effectively use SQL for common statistical operations from means and standard deviations to weighted moving averages.
  • Temporal data. Recipes demonstrate how to construct queries against time-based data.
  • Data Structures. This chapter shows how to manipulate data structures like stacks, queues, matrices, and arrays.
With an abundance of recipes to help you get your job done more efficiently, the Transact-SQL Cookbook is sure to become an essential part of your library.
27.99 In Stock
Transact-SQL Cookbook: Help for Database Programmers

Transact-SQL Cookbook: Help for Database Programmers

Transact-SQL Cookbook: Help for Database Programmers

Transact-SQL Cookbook: Help for Database Programmers

eBook

$27.99 

Available on Compatible NOOK devices, the free NOOK App and in My Digital Library.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

This unique cookbook contains a wealth of solutions to problems that SQL programmers face all the time. The 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. Authors Ales Spetic and Jonathan Gennick, two authorities with extensive database and SQL programming experience, include a discussion with each recipe to explain the logic and concepts underlying the solution.SQL (Structured Query Language) is the closest thing to a standard query language that currently exists, and Transact-SQL -- a full-featured programming language that dramatically extends the power of SQL -- is the procedural language of choice for both Microsoft SQL Server and Sybase SQL Server systems. The Transact-SQL Cookbook is designed so you can use the recipes directly, as a source of ideas, or as a way to learn a little more about SQL and what you can do with it. Topics covered include:

  • Audit logging. In addition to recipes for implementing an audit log, this chapter also includes recipes for: improving performance where large log tables are involved; supporting multiple-languages; and simulating server push.
  • Hierarchies. Recipes show you how to manipulate hierarchical data using Transact-SQL.
  • Importing data. This chapter introduces concepts like normalization and recipes useful for working with imported data tables.
  • Sets. Recipes demonstrate different operations, such as how to find common elements, summarize the data in a set, and find the element in a set that represents an extreme.
  • Statistics. This chapter's recipes show you how to effectively use SQL for common statistical operations from means and standard deviations to weighted moving averages.
  • Temporal data. Recipes demonstrate how to construct queries against time-based data.
  • Data Structures. This chapter shows how to manipulate data structures like stacks, queues, matrices, and arrays.
With an abundance of recipes to help you get your job done more efficiently, the Transact-SQL Cookbook is sure to become an essential part of your library.

Product Details

ISBN-13: 9780596552039
Publisher: O'Reilly Media, Incorporated
Publication date: 03/19/2002
Sold by: Barnes & Noble
Format: eBook
Pages: 304
File size: 3 MB

About the Author

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.

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 Universityin 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.

Table of Contents

Prefacexi
1.Pivot Tables1
Using a Pivot Table1
2.Sets5
Introduction5
The Students Example12
Implementing Set Difference13
Comparing Two Sets for Equality16
Implementing Partial Intersection18
Implementing Full Intersection21
Classifying Subsets22
Summarizing Classes of Sets24
Aggregating Aggregates26
Summarizing Aggregated Classes27
Including Nonaggregated Columns28
Finding the Top N Values in a Set30
Reporting the Size of a Set's Complement33
Finding the Complement of a Set34
Finding the Complement of a Missing Set36
Finding Complements of Sets with Different Universes38
Comparing a Set with Its Universe39
Dynamic Classification System40
3.Data Structures45
Types of Data Structures45
Working Example50
Finding Regions53
Reporting Region Boundaries54
Limiting Region Size55
Ranking Regions by Size57
Working with Sequences58
Working with Runs60
Cumulative Aggregates in Lists61
Implementing a Stack63
Implementing Queues65
Implementing Priority Queues66
Comparing Two Rows in an Array67
Printing Matrices and Arrays69
Transposing a Matrix70
Calculating a Matrix Trace71
Comparing Two Matrices for Size72
Adding and Subtracting Matrices73
Multiplying Matrices74
4.Hierarchies in SQL78
Types of Hierachies79
Creating a Permission Hierarchy84
Changing Individual Permissions88
Adding New Individual Permissions90
Centralizing Authorization Logic92
Implementing General Hierarchies93
Traversing Hierarchies Recursively96
Manipulating Hierarchies Recursively99
Aggregating Hierarchies100
Preparing Multilevel Operations103
Aggregating Hierarchies Revised106
5.Temporal Data110
Introduction110
The Schedules Example119
Enforcing Granularity Rules119
Storing Out-of-Range Temporal Values121
Deriving the First and Last Dates of the Month122
Printing Calendars124
Calculating Durations126
Reporting Durations128
Querying Periods129
Querying Periods and Respecting Granularity130
Finding Available Periods132
Finding Common Available Periods134
Excluding Recurrent Events135
Excluding Nonrecurring Events136
Finding Continuous Periods138
Using Calendar Information with Periods145
Using Calendar Information with Durations147
6.Audit Logging150
Audit Logs150
The Warehouse Example155
Row-Level Logging155
Reporting Log Events160
Generating Current Snapshots163
Generating Time-Restricted Snapshots165
Undoing Table Changes166
Minimizing Audit-Log Space Consumption168
Online Account Balancing173
Activity-Level Logging178
Partitioning Large Log Tables183
Server Push184
7.Importing and Transforming Data189
Considerations When Importing Data189
Working Examples196
Importing External Data198
Importing Data into a Live System200
Importing with a Single Procedure204
Hiding the Import Procedure205
Folding Tables208
Pivoting Tables211
Joining Arrays with Tables215
Joining Arrays with Master Tables217
Joining Arrays with Multiple Master Records219
Extracting Master Records from Tables220
Generating Master Records Online223
Working with Duplicates229
8.Statistics in SQL235
Statistical Concepts236
The Light-Bulb Factory Example249
Calculating a Mean252
Calculating a Mode253
Calculating a Median255
Calculating Standard Deviation, Variance, and Standard Error259
Building Confidence Intervals260
Calculating Correlation261
Exploring Patterns with Autocorrelation262
Using a Simple Moving Average265
Extending Moving Averages267
AppendixThe T-Distribution Table271
Index273
From the B&N Reads Blog

Customer Reviews