Académique Documents
Professionnel Documents
Culture Documents
Agenda
Data Types SQL Query Language Procedural Language CLR Integration Globalization Beyond Relational Other
Precision 10 16
34 27 19
Scale 0 7
7 7 0
Full SNAC (ODBC and OLEDB) support in Katmai Full SqlClient/ADO.net support in Orcas
SQL DATE ODBC SQL_TYPE_DATE/SQL_DATE OLEDB DBTYPE_DBDATE DateTime TIME SQL_TIME/SQL_SS_TIME2 DBTYPE_DBTIME/DBTYPE _DBTIME2 DBTYPE_DBTIMESTAMPOF FSET DBTYPE_DBTIMESTAMP TimeSpan ADO.NET
DATETIMEOFFSET
SQL_SS_TIMESTAMPOFFSET
DateTimeOffset
DATETIME2
SQL_TYPE_TIMESTAMP SQL_TIMESTAMP
DateTime
INSERT INTO t1 VALUES ('0001-01-01', '23:59:59', '0001-12-21 23:59:59.1234567', '0001-10-21 23:59:59.1234567 -07:00');
INSERT INTO t1 VALUES ('9999-12-31', '23:59:59', '9999-12-31 23:59:59.1234567', '1111-10-21 23:59:59.1234567 -07:00'); SELECT c4, DATEPART(TZOFFSET, c4), DATEPART(ISO_WEEK, c4), DATEPART(MICROSECOND, c4) FROM t1;
Large UDTs
SQL Server 2005
User-Defined Types (UDTs) limited to 8K bytes Fine for most objects, but some spatial objects could be quite large
Benefits
Usability, Type Matching, Precise Typing CREATE TYPE myTAS table (a int, b varchar(100))
Agenda
Data Types SQL Query Language Procedural Language CLR Integration Globalization Beyond Relational Other
MERGE
New DML statement that combines multiple DML operations
Building block for more efficient ETL SQL-2006 compliant implementation
Source
XXXXX XXX XXX XXXX XXX XXXXXXXXXX X XXX XXXX XX XX XXXX XXXXX XXX XX
MERGE
New DML statement that combines multiple DML operations
Building block for more efficient ETL SQL-2006 compliant implementation
Source Target
XXXXX XXX XXX XXXX XXX XXXXXXXXXX X XXX XXXX XX XX XXXX XXXXX XXX XX
XXXXX X XXXX
XXX XXX
MERGE
New DML statement that combines multiple DML operations
Building block for more efficient ETL SQL-2006 compliant implementation
Source Target
XXXXX XXX XXX XXXX XXX XXXXXXXXXX X XXX XXXX XX XX XXXX XXXXX XXX XX
XXX XXX
MERGE
New DML statement that combines multiple DML operations
Building block for more efficient ETL SQL-2006 compliant implementation
Source Target XXXXX XXX XXX XXXX XXX XXXXXXXXXX X XXX XXXX XX XX XXXX XXXXX XXX XX XXX XXX
XXXXX XXX XXX XXXX XXX XXXXXXXXXX X XXX XXXX XX XX XXXX XXXXX XXX XX
If no match, INSERT
MERGE
New DML statement that combines multiple DML operations
Building block for more efficient ETL SQL-2006 compliant implementation
Source Target XXXXX XXX XXX XXXX XXX
XXXXX XXX XXX XXXX XXX XXXXXXXXXX X XXX XXXX XX XX XXXX XXXXX XXX XX
Grouping Sets
Extension to the GROUP BY clause Ability to define multiple groupings in the same query Produces a single result set that is equivalent to a UNION ALL of differently grouped rows Makes aggregation querying and reporting easier and faster
Agenda
Data Types SQL Query Language Procedural Language CLR Integration Globalization Beyond Relational Other
a simple programming model. Strongly typed. Reduce client/server round trips Do not cause a statement to recompile.
Table-valued Parameters
Client Stack Support
Fully supported in ADO.Net 3
New Parameter type: SqlDbType.Structured Parameters can be passed in multiple ways
DataTable Ienumerable<SqlDataRecord> (fully streamed) DbDataReader
Table-valued Parameters
ADO.Net Example using DataTable
Using (MyConnection){ //Create a data table DataTabledt = new DataTable(TVPOrdersDataTable); dt.Columns.Add(ProductType, typeof(string)); dt.Columns.Add(Quantity, typeof(int)); // Add rows dt.Rows.Add(Canon Digital Camera, 20); dt.Rows.Add(June, 10); dt.Rows.Add(Xbox-360, 8); // Create a command and bind parameter SqlCommandtvp_cmd = new SqlCommand(sp_UpdataInventory, MyConnection); SqlParametertvpParam = tvp_cmd.Parameters.AddWithValue( @OrdersTvp, dt); //Execute command tvp_cmd.ExecuteNonQuery();
Scenarios
Discover all objects that a given object depends on Discover all objects that depend on a given object Discover all objects that depend on another database Discover all objects performing distributed queries using four-part names
New catalog view; replaces sys.sql_dependencies Tracks both schema-bound and non-schema-bound dependencies Tracks cross-database and cross-server references (by name)
sys.dm_sql_referenced_entities
New dynamic management function; replaces sp_depends Returns a row for each entity referenced by a given entity For example, show me all objects referenced in stored procedure p1
sys.dm_sql_referencing_entities
New dynamic management function; replaces sp_depends Returns a row for each entity that references a given entity For example, show me all objects that would be broken if I drop table t1
CREATE PROCEDURE p1 @a INT, @b myUDT OUTPUT AS DECLARE @x INT, @y INT; EXEC p2; GO SELECT <see column list below> FROM sys.sql_expression_dependencies WHERE referencing_id = OBJECT_ID(p1); SET @b = CAST (@x, @y) AS myUDT;
XXXXX XXX XXX XXXX XXX XXXXXXXXXX X XXX XXXX XX XX XXXX XXXXX XXX XX
Transaction Log
Capture Process
Source Table
CDC Functions
Change Table
s.sp_cdc_enable_table_change_data_capture
Source Table
XXX XXX XXXXXX XXX
Change Table
Agenda
Data Types SQL Query Language Procedural Language CLR Integration Globalization Beyond Relational Other
SQL/CLR Enhancements
Large aggregates
Store more than 8K bytes in state
Multi-input aggregates Specifying sort order and uniqueness for table-valued functions (TVFs)
Better performance
Agenda
Data Types SQL Query Language Procedural Language CLR Integration Globalization Beyond Relational Other
New Collations
Align with Windows Vista collations Adding Windows new collations in SQL Server 2008 Adding new versions to existing Windows collations (*_100_*) Adding new versions to existing Windows collations with SIGNIFICANT CHANGES
Chinese_Taiwan_Stroke_100 and Chinese_Taiwan_Bopomofo_100 will now assign culturecorrect weight for each character, specifically the Ext. A + B characters
Agenda
Data Types SQL Query Language Procedural Language CLR Integration Globalization Beyond Relational Other
Semi-Structured Data
Various enhancements to make SQL Server a better store for semi-structured data
XML: Improved schema and data model support. Hierarchy Id: compact encoding and representation of hierarchical data Sparse Columns: efficient storage of columns with sparsely populated values Large number of columns per table / index Filtered Indexes: indexing subsets of rows
HierarchyID
A system data type with variable length
CLR UDT Microsoft.SqlServer.Types Varbinary encoding ( < 900 bytes)
To represent position in a hierarchy Logically encodes information about a single node in a hierarchy tree by encoding the path from the root of the tree to the node Rich built-in methods for manipulating hierarchies Simplifies storage and querying of hierarchical data Comparison is in depth-first order, a<b means a comes before b in a depth first traversal of the tree Support for arbitrary insertions and deletions
// Sparse as a storage attibute in Create/Alter table statements Create Table Products(Id int, Type nvarchar(16), Resolution int SPARSE, ZoomLengthint SPARSE);
// No Change in Query/DML Behavior Select Id, Type, Resolution, ZoomLength from Products; Update Products set Resolution=3, ZoomLength = 105 where Id = 101;
Restrictions
Simple limited grammar for the predicate Only on non-clustered indexes
Benefits
Lower storage and maintenance costs for large number of indexes Query/DML Performance Benefits: IO only for qualifying rows
1 2
3 4 5 6 7
Camera Pant
Camera Camera Pant Pant ..
Canon Dockers
Nikon Pentax Polo Dockers
3x
5 Mb 38 34
300 45
600 195 30 40 32 32 65 45
5x 3x
10mb 3mb
// Create a Filtered Indexes Create Index ZoomIdx on Products(ZoomLength) where Type = Camera; Create Index PlusSizeIdx on Products(WaistSize) where Type = Pant and WaistSize> 36 // Optimizer will pick the filtered index when query predicates match Select ProductId, Type, Resolution, ZoomLength where Type = Camera Select ProductId, Type, WaistLength, Inseam where Type = Pant and WaistLength> 38 // DML operations need to maintain indexes only when needed. Insert into Products(ProductId, Type, waistLength, inseam) values (201, Pant, 30, 32);
Agenda
Data Types SQL Query Language Procedural Language CLR Integration Globalization Beyond Relational Other
Deprecation
Getting more serious about deprecation policy Deprecation announcements since SQL 7.0
Formalized policy in SQL Server 2005
Deprecation stages
Announcement/Warning Final support/Removal Future deprecation
More Resources
Technical Communities, Webcasts, Blogs, Chats, and User Groups www.microsoft.com/communities/default.mspx
Announcements
2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.