T-SQL Enhancements in SQL Server 2011 (CTP1)
SQL Server 2011 (code named Denali) CTP1 was announced in November 2010 during the SQL PASS Summit in Seattle. While a bit disappointing not to see the much anticipated full implementation of the window functions (hope we will still see that in a future CTP version), it offers some interesting new programmability features. These new enhancements address specific problems that we see very often in business applications. Here is a quick look at the key new features in T-SQL.
Feature: OFFSET
Application use: paging
Comments: provides simplified syntax and efficient method for data paging solutions
Listing 1: OFFSET example |
CREATE TABLE Customers (
|
Feature: THROW
Application use: error handling
Comments: allow to re-throw the original error
Listing 2: THROW example |
BEGIN TRY
|
Feature: SEQUENCE
Application use: replacement for IDENTITY
Comments: ANSI standard method for sequences, improves on shortcomings of IDENTITY
Listing 3: SEQUENCE example |
CREATE TABLE Customers (
|
Feature: EXECUTE WITH RESULT SETS
Application use: manipulate stored procedure output result set
Comments: capabilities to rename output result set columns without changing the original stored procedure; no options to remove/add columns or remove a result set when multiple result sets are returned
Listing 4: EXECUTE WITH RESULT SETS example |
CREATE PROCEDURE CalculateSales
|
Feature: describe result sets
Application use: determining the format of a response without actually running the query
Comments: replaces SET FMTONLY
Listing 5: Describe result sets example |
CREATE PROCEDURE CalculateSales
|
Bonus feature (maybe): FORMATMESSAGE
Application use: format messages (C/C++ sprint style)
Comments: undocumented feature allows to format message that is not in sys.messages
Listing 6: FORMATMESSAGE example |
SELECT FORMATMESSAGE('There are %d products in department %s.', 10, 'remodeling');
|
Leave a Reply
Want to join the discussion?Feel free to contribute!