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
  • Demo: Row Constructors
  • Demo: Grouping Sets
  • Demo: Inserting, Updating, and Deleting Data by Using MERGE
  • Presentation: T-SQL Improvements And Data Types