SQL Server 2008 - Transact-SQL Improvements
SQL Server 2008 introduces several enhancements to Transact-SQL.
The GROUP BY clause now includes GROUPING SETS, ROLLUP, and CUBE operators that provide varying levels of aggregate information. A new function, GROUPING_ID(), returns more grouping-level information than the existing GROUPING() function.
A new MERGE Transact-SQL statement allows you to perform INSERT, UPDATE, or DELETE operations on a target table based on the results of a join with a source table. The syntax allows you to perform multiple actions based on the results of that join.
Stored procedures and functions can now include table-valued parameters that can reference user-defined table types. Using table-valued parameters, you can send multiple rows of data to a SQL Server statement or routine without creating a temporary table.
Row constructors in Transact-SQL provide a simplified syntax that allows multiple row inserts within a single INSERT statement. Using row constructors, the entire insertion operation executes inside a transaction, implicit in the single INSERT statement itself.
Compound Operators provide a concise mechanism to perform logical and arithmetic operations on an operand and assign the result of the operation to that operand, for example, @x += 2 adds 2 to variable @x. In addition, you can now declare a variable and assign its value in the same statement.
Lessons
-
Demo: Table-Valued Parameters
This demo shows how to use table-valued parameters in SQL Server 2008 to send multiple rows of data to Transact-SQL statements or routines, without creating temporary tables or additional parameters. It illustrates how to declare user-defined table types
and use them to define strongly typed table…
-
Demo: Row Constructors
This demo shows how to use row constructors in SQL Server 2008 to insert multiple rows based on values in a single INSERT statement. In addition, it illustrates how to use row constructors as a data source and how to perform a query over its values.
-
Demo: Grouping Sets
This demo illustrates grouping sets in SQL Server 2008 and how you can use them to easily specify combinations of field groupings in your queries and obtain different levels of aggregated data.
-
Demo: Inserting, Updating, and Deleting Data by Using MERGE
This demo illustrates the syntax and semantics of the MERGE statement in SQL Server 2008. In general, MERGE applies a set of changes (INSERT/UPDATE/DELETE) in a single, transactional operation. The demo illustrates the inner workings of MERGE by exploring
its query plan.
-
Presentation: T-SQL Improvements And Data Types
This presentation provides an overview of the main Transact-SQL improvements in SQL Server 2008, including table-valued parameters (TVPs), row constructors, the new MERGE statement and GROUPING SETS, among others.