Book description
This comprehensive introduction to SQL Server begins with an overview of database design basics and the SQL query language along with an in-depth look at SQL Server itself
Progresses on to a clear explanation of how to implement fundamental concepts with the new 2008 version of SQL Server
Discusses creating and changing tables, managing keys, writing scripts, working with stored procedures, programming with XML, using SQL Server Reporting and Integration Services, and more
Features updated and new material, including new examples using Microsoft's AdventureWorks sample database
Table of contents
- Copyright
- About the Author
- Credits
- Acknowledgments
- Introduction
-
1. RDBMS Basics: What Makes Up a SQL Server Database?
-
1.1. An Overview of Database Objects
-
1.1.1. The Database Object
- 1.1.1.1. The master Database
- 1.1.1.2. The model Database
- 1.1.1.3. The msdb Database
- 1.1.1.4. The tempdb Database
- 1.1.1.5. ReportServer
- 1.1.1.6. ReportServerTempDB
- 1.1.1.7. AdventureWorks2008
- 1.1.1.8. AdventureWorksLT2008
- 1.1.1.9. AdventureWorksDW2008
- 1.1.1.10. The pubs Database
- 1.1.1.11. The Northwind Database
- 1.1.2. The Transaction Log
- 1.1.3. The Most Basic Database Object: Table
- 1.1.4. Filegroups
- 1.1.5. Diagrams
- 1.1.6. Views
- 1.1.7. Stored Procedures
- 1.1.8. User-Defined Functions
- 1.1.9. Users and Roles
- 1.1.10. Rules
- 1.1.11. Defaults
- 1.1.12. User-Defined Data Types
- 1.1.13. Full-Text Catalogs
-
1.1.1. The Database Object
- 1.2. SQL Server Data Types
- 1.3. SQL Server Identifiers for Objects
- 1.4. Summary
-
1.1. An Overview of Database Objects
- 2. Tools of the Trade
-
3. The Foundation Statements of T-SQL
-
3.1. Getting Started with a Basic SELECT Statement
- 3.1.1. The SELECT Statement and FROM Clause
- 3.1.2. The WHERE Clause
- 3.1.3. ORDER BY
- 3.1.4. Aggregating Data Using the GROUP BY Clause
- 3.1.5. Placing Conditions on Groups with the HAVING Clause
- 3.1.6. Outputting XML Using the FOR XML Clause
- 3.1.7. Making Use of Hints Using the OPTION Clause
- 3.1.8. The DISTINCT and ALL Predicates
- 3.2. Adding Data with the INSERT Statement
- 3.3. Changing What You've Got with the UPDATE Statement
- 3.4. The DELETE Statement
- 3.5. Summary
- 3.6. Exercises
-
3.1. Getting Started with a Basic SELECT Statement
- 4. JOINs
-
5. Creating and Altering Tables
- 5.1. Object Names in SQL Server
-
5.2. The CREATE Statement
- 5.2.1. CREATE DATABASE
-
5.2.2. CREATE TABLE
- 5.2.2.1. Table and Column Names
- 5.2.2.2. Data Types
- 5.2.2.3. DEFAULT
- 5.2.2.4. IDENTITY
- 5.2.2.5. NOT FOR REPLICATION
- 5.2.2.6. ROWGUIDCOL
- 5.2.2.7. COLLATE
- 5.2.2.8. NULL/NOT NULL
- 5.2.2.9. Column Constraints
- 5.2.2.10. Computed Columns
- 5.2.2.11. Table Constraints
- 5.2.2.12. ON
- 5.2.2.13. TEXTIMAGE_ON
- 5.2.2.14. Creating a Table
- 5.3. The ALTER Statement
- 5.4. The DROP Statement
- 5.5. Using the GUI Tool
- 5.6. Summary
- 5.7. Exercises
-
6. Constraints
- 6.1. Types of Constraints
- 6.2. Constraint Naming
- 6.3. Key Constraints
- 6.4. CHECK Constraints
- 6.5. DEFAULT Constraints
- 6.6. Disabling Constraints
- 6.7. Rules and Defaults — Cousins of Constraints
- 6.8. Triggers for Data Integrity
- 6.9. Choosing What to Use
- 6.10. Summary
- 7. Adding More to Our Queries
- 8. Being Normal: Normalization and Other Basic Design Issues
-
9. SQL Server Storage and Index Structures
- 9.1. SQL Server Storage
- 9.2. Understanding Indexes
- 9.3. Creating, Altering, and Dropping Indexes
- 9.4. Choosing Wisely: Deciding What Index Goes Where and When
- 9.5. Maintaining Your Indexes
- 9.6. Summary
- 9.7. Exercises
-
10. Views
- 10.1. Simple Views
- 10.2. More Complex Views
- 10.3. Editing Views with T-SQL
- 10.4. Dropping Views
- 10.5. Creating and Editing Views in the Management Studio
- 10.6. Auditing: Displaying Existing Code
- 10.7. Protecting Code: Encrypting Views
- 10.8. About Schema Binding
- 10.9. Making Your View Look Like a Table with VIEW_METADATA
- 10.10. Indexed (Materialized) Views
- 10.11. Summary
- 10.12. Exercises
-
11. Writing Scripts and Batches
- 11.1. Script Basics
- 11.2. Batches
- 11.3. sqlcmd
- 11.4. Dynamic SQL: Generating Your Code On the Fly with the EXEC Command
- 11.5. Control-of-Flow Statements
- 11.6. Summary
- 11.7. Exercises
-
12. Stored Procedures
- 12.1. Creating the Sproc: Basic Syntax
- 12.2. Changing Stored Procedures with ALTER
- 12.3. Dropping Sprocs
- 12.4. Parameterization
- 12.5. Confirming Success or Failure with Return Values
- 12.6. More On Dealing with Errors
- 12.7. What a Sproc Offers
- 12.8. Extended Stored Procedures (XPs)
- 12.9. A Brief Look at Recursion
- 12.10. Debugging
- 12.11. .NET Assemblies
- 12.12. Summary
- 13. User-Defined Functions
-
14. Transactions and Locks
- 14.1. Transactions
- 14.2. How the SQL Server Log Works
- 14.3. Locks and Concurrency
- 14.4. Setting the Isolation Level
- 14.5. Dealing with Deadlocks (aka "a 1205")
- 14.6. Summary
-
15. Triggers
- 15.1. What Is a Trigger?
- 15.2. Using Triggers for Data Integrity Rules
- 15.3. Other Common Uses for Triggers
- 15.4. Other Trigger Issues
- 15.5. INSTEAD OF Triggers
-
15.6. Performance Considerations
- 15.6.1. Triggers Are Reactive Rather Than Proactive
- 15.6.2. Triggers Don't Have Concurrency Issues with the Process That Fires Them
- 15.6.3. Using IF UPDATE() and COLUMNS_UPDATED
- 15.6.4. Keep It Short and Sweet
- 15.6.5. Don't Forget Triggers When Choosing Indexes
- 15.6.6. Try Not to Roll Back Within Triggers
- 15.7. Dropping Triggers
- 15.8. Debugging Triggers
- 15.9. Summary
-
16. A Brief XML Primer
- 16.1. XML Basics
-
16.2. What SQL Server Brings to the Party
- 16.2.1. Defining a Column as Being of XML Type
- 16.2.2. XML Schema Collections
- 16.2.3. Creating, Altering, and Dropping XML Schema Collections
- 16.2.4. XML Data Type Methods
- 16.2.5. Enforcing Constraints Beyond the Schema Collection
- 16.2.6. Retrieving Relational Data in XML Format
- 16.2.7. RAW
- 16.2.8. AUTO
- 16.2.9. EXPLICIT
- 16.2.10. PATH
- 16.2.11. OPENXML
- 16.3. A Brief Word on XSLT
- 16.4. Summary
- 17. Reporting for Duty, Sir! A Look At Reporting Services
-
18. Getting Integrated with Integration Services
- 18.1. Understanding the Problem
- 18.2. Using the Import/Export Wizard to Generate Basic Packages
- 18.3. Examining Package Basics
- 18.4. Executing Packages
- 18.5. A Final Word on Packages
- 18.6. Summary
- 19. Playing Administrator
-
A. System Functions
- A.1. Legacy System Functions (a.k.a. Global Variables)
- A.2. Aggregate Functions
- A.3. Configuration Functions
-
A.4. Cryptographic Functions
- A.4.1. AsymKey_ID
- A.4.2. Cert_ID
- A.4.3. CertProperty
- A.4.4. DecryptByAsmKey
- A.4.5. DecryptByCert
- A.4.6. DecryptByKey
- A.4.7. DecryptByPassPhrase
- A.4.8. EncryptByAsmKey
- A.4.9. EncryptByCert
- A.4.10. EncryptByKey
- A.4.11. EncryptByPassPhrase
- A.4.12. Key_GUID
- A.4.13. Key_ID
- A.4.14. SignByAsymKey
- A.4.15. SignByCert
- A.4.16. VerifySignedByAsymKey
- A.4.17. VerifySignedByCert
- A.5. Cursor Functions
- A.6. Date and Time Functions
- A.7. Hierarchy Functions
- A.8. Mathematical Functions
-
A.9. Basic Metadata Functions
- A.9.1. COL_LENGTH
- A.9.2. COL_NAME
- A.9.3. COLUMNPROPERTY
- A.9.4. DATABASEPROPERTY
- A.9.5. DATABASEPROPERTYEX
- A.9.6. DB_ID
- A.9.7. DB_NAME
- A.9.8. FILE_ID
- A.9.9. FILE_NAME
- A.9.10. FILEGROUP_ID
- A.9.11. FILEGROUP_NAME
- A.9.12. FILEGROUPPROPERTY
- A.9.13. FILEPROPERTY
- A.9.14. FULLTEXTCATALOGPROPERTY
- A.9.15. FULLTEXTSERVICEPROPERTY
- A.9.16. INDEX_COL
- A.9.17. INDEXKEY_PROPERTY
- A.9.18. INDEXPROPERTY
- A.9.19. OBJECT_ID
- A.9.20. OBJECT_NAME
- A.9.21. OBJECTPROPERTY
- A.9.22. OBJECTPROPERTYEX
- A.9.23. @@PROCID
- A.9.24. SCHEMA_ID
- A.9.25. SCHEMA_NAME
- A.9.26. SQL_VARIANT_PROPERTY
- A.9.27. TYPEPROPERTY
- A.10. Rowset Functions
- A.11. Security Functions
-
A.12. String Functions
- A.12.1. ASCII
- A.12.2. CHAR
- A.12.3. CHARINDEX
- A.12.4. DIFFERENCE
- A.12.5. LEFT
- A.12.6. LEN
- A.12.7. LOWER
- A.12.8. LTRIM
- A.12.9. NCHAR
- A.12.10. PATINDEX
- A.12.11. QUOTENAME
- A.12.12. REPLACE
- A.12.13. REPLICATE
- A.12.14. REVERSE
- A.12.15. RIGHT
- A.12.16. RTRIM
- A.12.17. SOUNDEX
- A.12.18. SPACE
- A.12.19. STR
- A.12.20. STUFF
- A.12.21. SUBSTRING
- A.12.22. UNICODE
- A.12.23. UPPER
-
A.13. System Functions
- A.13.1. APP_NAME
- A.13.2. CASE
- A.13.3. CAST and CONVERT
- A.13.4. COALESCE
- A.13.5. COLLATIONPROPERTY
- A.13.6. CURRENT_USER
- A.13.7. DATALENGTH
- A.13.8. @@ERROR
- A.13.9. FORMATMESSAGE
- A.13.10. GETANSINULL
- A.13.11. HOST_ID
- A.13.12. HOST_NAME
- A.13.13. IDENT_CURRENT
- A.13.14. IDENT_INCR
- A.13.15. IDENT_SEED
- A.13.16. @@IDENTITY
- A.13.17. IDENTITY
- A.13.18. ISNULL
- A.13.19. ISNUMERIC
- A.13.20. NEWID
- A.13.21. NULLIF
- A.13.22. PARSENAME
- A.13.23. PERMISSIONS
- A.13.24. @@ROWCOUNT
- A.13.25. ROWCOUNT_BIG
- A.13.26. SCOPE_IDENTITY
- A.13.27. SERVERPROPERTY
- A.13.28. SESSION_USER
- A.13.29. SESSIONPROPERTY
- A.13.30. STATS_DATE
- A.13.31. SYSTEM_USER
- A.13.32. USER_NAME
- A.14. Text and Image Functions
- B. Very Simple Connectivity Examples
Product information
- Title: Beginning Microsoft® SQL Server® 2008 Programming
- Author(s):
- Release date: January 2009
- Publisher(s): Wrox
- ISBN: 9780470257012
You might also like
book
Programming Microsoft® SQL Server™ 2008
Extend your programming skills with a comprehensive study of the key features of SQL Server 2008. …
book
Professional Microsoft® SQL Server® 2008 Programming
Master the increasingly complex feature set of the latest release of Microsoft SQL Server with the …
book
Microsoft® SQL Server® 2008 For Dummies®
If you’re a database administrator, you know Microsoft SQL Server 2008 is revolutionizing database development. Get …
book
Inside Microsoft® SQL Server® 2008: T-SQL Programming
Get a detailed look at the internal architecture of T-SQL with this comprehensive programming reference. Database …