T Sql Cookbook Microsoft Sql Server 2012 Enhancements
July 17, 2026 · 689 KB
Transcript of a Microsoft presentation on new T-SQL features in SQL Server 2012, from paging and sequences to window functions, error handling, new functions, metadata discovery and Dynamic SQL.
Overview
This is the transcript of a recorded Microsoft presentation, given by Tobias Ternstrom, a lead program manager on the SQL Server Engine team, about what was new for programmers in SQL Server 2012. He demonstrates each feature with live queries against Microsoft's AdventureWorks sample database. As a product presentation, it promotes the release and ends by encouraging viewers to try it.
New Query and Schema Features
The talk opens with several additions:
- Simplified paging, using new OFFSET and FETCH clauses to skip and return set numbers of rows, which requires an ORDER BY clause and, the presenter advises, should include a unique column for consistent pages
- Fuller support for UTF-16 supplementary characters, such as ancient scripts and music notation, through new collations, so string functions handle them correctly
- Sequence generators, which separate number generation from storage so that, for example, employee and contractor IDs can be unique across two tables, while the existing IDENTITY property remains supported
- Extended window functions, including running totals over framed partitions, in line with the ANSI SQL standard
Error Handling and Functions
The presenter covers improvements to error handling, building on the TRY and CATCH blocks added in SQL Server 2005, as an alternative to the older RAISERROR command. New scalar functions include TRY_CONVERT and TRY_CAST, which return null instead of failing when a conversion is not possible, and date functions such as EOMONTH, which returns the last day of a month.
Metadata Discovery and Dynamic SQL
New procedures let tools work out the shape of a query's results without running it, correctly handling batches where different branches return different results, in place of the older SET FMTONLY approach. Another procedure, which the presenter jokingly calls the "Jedi mind trick", identifies undeclared parameters in a query. Finally, the EXECUTE statement gains a RESULT SETS clause, letting callers specify exactly what a stored procedure or Dynamic SQL batch must return, and causing an error if it returns anything different.
Why It Matters
The transcript is a clear, example-led tour of the programmability changes in SQL Server 2012, useful for developers moving from earlier versions.
