See What we are Talking About!
SQL 2012 Tips for Developers
By: Joe Cuesta, CommitDBA staff Database Administrator
October 10, 2012
SQL 2012 is packed with some great new features. The enhanced look alone of SSMS tells you its definitely starting to take on more of the Visual Studio feel. Below are just a couple of the new features in SQL 2012.
One of the new features the web guys are sure to love is the new pagination features of order by using offset and next only. While reducing the amount of rows in a result set, it also helps improve performance. No more selecting all the rows from a query and paging through the results, now you can select only the rows you need.
Below is an example from the Adventureworks2012 database; this example returns 20 rows starting at row 20:
Select [BusinessEntityID], [Name]
Order By [BusinessEntityID]
Offset 20 Rows
Fetch Next 20 Rows only
Another new feature in SQL 2012 is sequences. Sequences have been around a long time in Oracle and they are finally here in SQL Server 2012. A sequence is a user defined object which is used to generate a sequence of numbers. It is similar to an identity but it is independent of the table.
Sequences are much more flexible than identities and are easier to generate and view the next ID. Other advantages of sequences include setting maximum values, reseeding and changing step size, cycling the sequence or even de-incrementing.
Below is a simple way to create a sequence that will show up in the database under Programmability -> Sequences:
Create Sequnce [dbo].[Sequence_1]
These are just two of the many great features added to SQL Server 2012 which should be of great use to you. Next time focus will be on features for the DBA followed by new and improved BI design and development.