Contents

Figures

Tables

Foreword

Foreword

Preface

Acknowledgments

About the Authors

1. Introduction

The .NET Framework and the Microsoft Platform

The .NET Framework’s Effects on SQL Server

The SQL:1999 Standard: Extending the Relational Model

User-Defined Types and SQL Server

XML: Data and Document Storage

Web Services: XML As a Marshaling Format

Client Access . . . And Then There Are Clients

Client-Side Database APIs and SQL Server 2005

Client-Side XML-Based APIs and SQL Server 2005 Integration

Extending SQL Server into the Platform: Service Broker and Notification Services

Where Are We?

2. Hosting the Runtime: SQL Server As a Runtime Host

Why Care How Hosting Works?

What Is a .NET Framework Runtime Host?

SQL Server As a Runtime Host

SQL Server Resource Management

Exceptional Condition Handling

Code Loading

Security

Loading the Runtime: Processes and AppDomains

Safe Code: How the Runtime Makes It Safer to Run “Foreign” Code

Where the Code Lives: Storing .NET Framework Assemblies (CREATE ASSEMBLY)

Assembly Dependencies: When Your Assemblies Use Other Assemblies

Assemblies and SQL Schemas: Who Owns Assemblies (Information Schema)

System Metadata Tables and INFORMATION_SCHEMA

Assembly Metadata

Maintaining User Assemblies (ALTER ASSEMBLY, DROP ASSEMBLY)

Specification Compliance

Conclusions

Where Are We?

3. Procedures and Functions in .NET CLR Languages

Extending SQL Server

CLR Extension Basics

CLR Extension Details

System.Data.SqlTypes

A Few Words About Null Values

Using SqlTypes

Parameters and Return Value

User-Defined Functions

Table-Valued Functions

Stored Procedures

Triggers

Where Are We?

4. In-Process Data Access

Programming with SqlClient

Context: The SqlContext Class

Connections

Commands: Making Things Happen

Obtaining Results

Transactions

TransactionScope Exotica

Best Practices

Pipe

Creating and Sending New Rowsets

Using the WindowsIdentity

Calling a Web Service from SQLCLR

Exception Handling

SqlTriggerContext

SqlClient Classes That You Can’t Use on the Server

Where Are We?

5. User-Defined Types and Aggregates

Why Do We Need User-Defined Types?

Overview of User-Defined Types

Creating a User-Defined Type

Null Value Implementation

String Implementation

Binary Implementation

IBinarySerialize.Read/Write

Creating User-Defined Types

Public Properties, Fields, and Methods

Helper Functions

User-Defined-Type Validation

Maintaining User-Defined-Type Definitions

User-Defined Types and XML

Should Objects Be Represented by User-Defined Types?

User-Defined Aggregates

Implementing a User-Defined Aggregate

Creating User-Defined Aggregate

Format.Native vs. Format.UserDefined

Where Are We?

6. Security

New Security Features in SQL Server 2005

Optional Features Are Turned Off by Default

Configuring Security Settings

Security and Metadata

A Quick Review of SQL Server Security Concepts with Enhancements

Authentication and Authorization: Principals and Permissions

Execution Context and Ownership Chaining

SQL Server Password Policies and Credentials

Encryption Keys and Built-In Encryption Functions

Encryption Functions

Separation of Users and Schemas

Synonyms

Specifying Execution Context for Procedural Code

Code Signing

SQL Server Permissions and SQLCLR Objects

Assembly Permissions: Who Can Catalog and Use an Assembly?

What .NET Framework Code Can Do from within SQL Server: Safety Levels

Introduction to Code Access Security

Code Access Security and .NET Framework Assemblies

Where Are We?

7. SQL Engine Enhancements

Improvements to the SQL Engine

SNAPSHOT Isolation

Drawbacks of Versioning

Monitoring Versioning

Data Definition Language Triggers

Event Notifications

Large Value Data Types

Loading Data with the New BULK Provider

Statement-Level Recompilation

Query Hints, Plan Guides, and Plan Forcing

Where Are We?

8. T-SQL Language Enhancements

Improvements to Transact-SQL

Error Handling

INTERSECT and EXCEPT

Top

ON DELETE and ON UPDATE

Output

APPLY Operators

Common Table Expressions

Recursive Queries

PIVOT and UNPIVOT Operators

Pivot

Unpivot

Ranking and Partitioning

ROW_NUMBER

Rank

DENSE_RANK

Ntile

Partition By

Aggregate Partitions

Tablesample

Where Are We?

9. XML in the Database: The XML Data Type

The XML Data Type

Using XML Data Type in Tables

Using XML Data Variables and Parameters

Typed and Untyped XML: Cataloguing and Using XML SCHEMA COLLECTIONs

SQL Server XML SCHEMA COLLECTIONs

Typed XML

Management of XML Schemas and Schema Collections

Security for XML SCHEMA COLLECTIONS and Strongly Typed Instances

Creating an Index on an XML Column

XML Type Functions

SELECT . . . FOR XML Enhancements

FOR XML PATH Mode

Producing an XML Data Type

Producing an Inline XSD Format Schema

NULL Database Values

Producing a Root Element

Other Features

Mapping SQL and XML Data Types

Mapping SQL Types to XML Types

String, Binary, and Decimal Types

Other General Data Types

Date Data Type

Pattern-Based Data Types

Wildcard Data Types

Nullability

OpenXML Enhancements

Loading XML into the Database from Files

ANSI SQL Standard Compliance

XML Data Type

Mapping SQL Catalogs and Tables to XML

Mapping SQL Data Types to XML Data Types

Where Are We?

10. XML Query Languages: XQuery and XPath

What Is XQuery?

An Introduction to XQuery

The XQuery Prolog

The XQuery Body

Comparing and Contrasting XQuery and SQL

Using XQuery with the XML Data Type

xml.exist(string xquery-text)

xml.value(string xquery-text, string SQLType)

xml.query(string xquery-text)

xml.nodes(string xquery-text)

XQuery Standard Functions and Operators

SQL Server XQuery Functions and Operators

XQuery Functions Supported by SQL Server

Data Accessor Functions

Functions on Numeric Values

Functions on String Values

Constructors and Functions on Booleans

Functions on Nodes

Context Functions

Functions on Sequences

Aggregate Functions

Functions Related to QNames

Constructor Functions

XQuery Operators Supported by SQL Server

SQL Server XQuery Extended Functions

Multiple-Document Query in SQL Server XQuery

XML DML: Updating XML Columns

xml.modify(‘insert . . .’)

xml.modify(‘delete . . .’)

xml.modify(‘replace value of . . .’)

General Conclusions and Best Practices

Special Considerations When Using XQuery Inside SQL Server

XML Schemas and SQL Server 2005 XQuery

XML Indexes Usage in XQuery

Where Are We?

11. SQL Server Service Broker

Messaging Applications

Processing Messages

Business Transactions

Service Programs

Conversations

Conversation Groups

Message Types

Contracts

Send and Message Type

Processing Loop

Poison Messages

Compensation

Distribution

Where Are We?

12. SQL Server As a Platform for Web Services

Mixing Databases and Web Services

HTTP Endpoint Declaration

Create Endpoint

Endpoint URL

Endpoint State

Endpoint Metadata

Webmethods

WSDL Web Service Definition Language

XML Namespaces

WSDL Generation

Stored Procedure in Web Service

SQL Batches

Other Features

SQLXML 4.0 Functionality and SQL Server 2005

Where Are We?

13. SQL Server 2005 and Clients

SQL Native Client

New Data Types and Data Type Compatibility Mode

User-Defined Types and Relational Data Access APIs

Using .NET Framework UDTs in ADO.NET

Fetching UDT Data from a DataReader

Using .NET Framework UDTs in ODBC, OLE DB, and ADO Clients

Supporting the XML Data Type on the Client

Using the XML Data Type in ADO.NET

Getting the XML As XML or a String

Documents, Fragments, and FOR XML Support

Using the XML Data Type in ADO Classic

Supporting the Large Value Data Types on the Client

Query Notification Support

Query Notifications in SQL Server 2005

Using Query Notifications in OLE DB and ODBC

Dispatching a Notification to an End User or Cache

Using Query Notifications from a Database Client

Using SqlDependency

Using SqlNotificationRequest

Using SqlCacheDependency in ASP.NET

Eager Notifications

When Not to Use Notifications

Multiple Active Resultsets

Using MARS in ADO.NET 2.0

MARS in SQL Native Client

New Transaction and Isolation Features in ADO.NET

Using the New Isolation Levels

Promotable and Declarative Transactions

Changes Related to SQL Server 2005 Login

Password Change Support

Failover Support

Encryption Support

Comparing the Client and Server Model for Stored Procedures

Where Are We?

14. ADO.NET 2.0 and SqlClient

Generic Coding with the ADO.NET 2.0 Base Classes and Factories

Provider Factories

Specifying Configuration Information

Enumerating Data Sources and Building Connection Strings

Other Generic Coding Considerations

Schemas in ADO.NET 2.0

Who Needs Metadata, Anyway?

What Metadata Is Available?

Customizing and Extending the Metadata

User Customization

Tracing Data Access

Setting Up Data Tracing

Running the Trace

Harvest the Results As a CSV File

Reading the Trace Output

User Data and ADO.NET Tracing

Configuring Which Applications Are Traced

Using Tracing to Debug a Parameter Binding Problem

Inside Data Tracing

What Is ETW?

Asynchronous Support

Bulk Import in SqlClient

Client Statistics

.NET Framework DataSet and SqlDataAdapter Enhancements

Where Are We?

15. SQL Server Management Objects

Introduction

Why Use SMO?

ADO vs. SMO

Object Model

SMO Projects

Connections

Default Windows Credentials Connection

Using Runas

Automatic Connection

Windows Identity Impersonation

SQL Server Login

Changing SQL Server Login Password

Connection Management

Server

SMO Objects

Object Identity and URNs

GetSmoObject

URN Retrieval Restriction

SMO Object Model

SMO Properties

SMO Parent Navigation

SMO State

Create, Alter, and Drop

Scripts

Configuration Management

Where Are We?

16. Notification Services

What Is SQL Server Notification Services?

Notification Applications

Components of SQL Server Notification Services

Notification Applications Design Patterns

Notification Services Delivery Features

Terms Used in Notification Services

Designing, Coding, and Generating a Notification Services Application

Planning Steps

Coding Steps

Application Generation Steps

A Sample Notification Application

Instance and Application Configuration Files

Instance Configuration File

Application Definition File

NSControl

Events

Event Classes

Event Stored Procedures

Event Providers

Chronicles

Subscribers and Subscriptions

Subscription Classes

Subscribers

Subscriptions

Notifications

Distributor and Formatters

Delivery

Delivery Protocols

Customization

Where Are We?

17. Wrap-Up: Service-Oriented Database Applications

Lots of New Features: How to Use Them

Data Models, Programming, and SQL Server

Any Functionality at Any Tier

What Are the Best Practices?

Toward a Service-Oriented Database Architecture

The Database As Part of the Platform

Appendixes

A. .NET Framework 101

The Common Language Runtime

Development Languages

Assemblies and Modules

Modules

Assemblies

Assembly Names and Versions

The CLR Type System

Classes and Types

Visibility

Instances

Namespaces

Members of Types

Fields and Properties

Parameters and Methods

Memory Management

Finalization and Destructors

Disposing

B. SQL Server Management Studio

Introduction

Solutions and Projects

Configuration

Making a Solution/Project

Templates

Object Explorer

C. Visual Studio 2005 Integration: SQL Server Projects

Visual Studio 2005

Custom Attributes and Automatic Deployment

Automatic Deployment

Data Types and SqlFacet

Executing and Debugging the Code

References

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.203.68