Top 12 Features of SQL Server 2012 Microsoft has introduced SQL Server 2012 to the world and it's time for IT professionals to start to come to speed on what's new. Microsoft has introduced SQL Server 2012 to the world and it's time for IT professionals to start to come to speed on what's new in this highly anticipated version of SQL Server. 1. AlwaysOn Availability Groups -- This feature takes database mirroring to a whole new level. With AlwaysOn, users will be able to fail over multiple databases in groups instead of individually. Also, secondary copies will be readable, and can be used for database backups. The big win is that your DR environment no longer needs to sit idle. 2. Windows Server Core Support -- If you don't know what Windows Server Core is, you may want to come up to speed before Windows 8 (MS is making a push back to the command line for server products). Core is the GUI-less version of Windows that uses DOS and PowerShell for user interaction. It has a much lower footprint (50% less memory and disk space utilization), requires fewer patches, and is more secure than the full install. Starting with SQL 2012, it is supported for SQL Server. 3. Columnstore Indexes -- This a cool new feature that is completely unique to SQL Server. They are special type of read-only index designed to be use with Data Warehouse queries. Basically, data is grouped and stored in a flat, compressed column index, greatly reducing I/O and memory utilization on large queries. 4. User-Defined Server Roles -- DBAs have always had the ability to create custom database role, but never server wide. For example, if the DBA wanted to give a development team read/write access to every database on a shared server, traditionally the only ways to do it were either manually, or using undocumented procedures. Neither of which were good solutions. Now, the DBA can create a role, which has read/write access on every DB on the server, or any other custom server wide role. 5. Enhanced Auditing Features -- Audit is now available in all editions of SQL Server. Additionally, users can define custom audit specifications to write custom events into the audit log. New filtering features give greater flexibility in choosing which events to write to the log. 6. BI Semantic Model -- This is replacing the Analysis Services Unified Dimensional Model (or cubes most people referred to them). It's a hybrid model that allows one data model will support all BI experiences in SQL Server. Additionally, this will allow for some really neat text infographics 7. Sequence Objects -- For those folks who have worked with Oracle, this has been a long requested feature. A sequence is just an object that is a counter -- a good example of it's use would be to increment values in a table, based a trigger. SQL has always had similar functionality with identity columns, but now this is a discrete object. 8. Enhanced PowerShell Support -- Windows and SQL Server admins should definitely start brushing up on their PowerShell scripting skills. Microsoft is driving a lot of development effort into instrumenting all of their server-based products with PowerShell. SQL 2008 gave DBAs some exposure to it, but there are many more in cmdlets in SQL 2012. 9. Distributed Replay -- Once again this is answer to a feature that Oracle released (Real Application Testing). However, and in my opinion where the real value proposition of SQL Server is, in Oracle it is a (very expensive) cost option to Enterprise Edition. With SQL, when you buy your licenses for Enterprise Edition, you get everything. Distributed replay allows you to capture a workload on a production
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Top 12 Features of SQL Server 2012Microsoft has introduced SQL Server 2012 to the world and it's time for IT professionals to start to come to speed on what's new.
Microsoft has introduced SQL Server 2012 to the world and it's time for IT professionals to start to come to speed on what's new in this highly anticipated version of SQL Server.
1. AlwaysOn Availability Groups -- This feature takes database mirroring to a whole new level. With AlwaysOn, users will be able to fail over multiple databases in groups instead of individually. Also, secondary copies will be readable, and can be used for database backups. The big win is that your DR environment no longer needs to sit idle.2. Windows Server Core Support -- If you don't know what Windows Server Core is, you may want to come up to speed before Windows 8 (MS is making a push back to the command line for server products). Core is the GUI-less version of Windows that uses DOS and PowerShell for user interaction. It has a much lower footprint (50% less memory and disk space utilization), requires fewer patches, and is more secure than the full install. Starting with SQL 2012, it is supported for SQL Server.3. Columnstore Indexes -- This a cool new feature that is completely unique to SQL Server. They are special type of read-only index designed to be use with Data Warehouse queries. Basically, data is grouped and stored in a flat, compressed column index, greatly reducing I/O and memory utilization on large queries.4. User-Defined Server Roles -- DBAs have always had the ability to create custom database role, but never server wide. For example, if the DBA wanted to give a development team read/write access to every database on a shared server, traditionally the only ways to do it were either manually, or using undocumented procedures. Neither of which were good solutions. Now, the DBA can create a role, which has read/write access on every DB on the server, or any other custom server wide role.5. Enhanced Auditing Features -- Audit is now available in all editions of SQL Server. Additionally, users can define custom audit specifications to write custom events into the audit log. New filtering features give greater flexibility in choosing which events to write to the log.6. BI Semantic Model -- This is replacing the Analysis Services Unified Dimensional Model (or cubes most people referred to them). It's a hybrid model that allows one data model will support all BI experiences in SQL Server. Additionally, this will allow for some really neat text infographics7. Sequence Objects -- For those folks who have worked with Oracle, this has been a long requested feature. A sequence is just an object that is a counter -- a good example of it's use would be to increment values in a table, based a trigger. SQL has always had similar functionality with identity columns, but now this is a discrete object.8. Enhanced PowerShell Support -- Windows and SQL Server admins should definitely start brushing up on their PowerShell scripting skills. Microsoft is driving a lot of development effort into instrumenting all of their server-based products with PowerShell. SQL 2008 gave DBAs some exposure to it, but there are many more in cmdlets in SQL 2012.9. Distributed Replay -- Once again this is answer to a feature that Oracle released (Real Application Testing). However, and in my opinion where the real value proposition of SQL Server is, in Oracle it is a (very expensive) cost option to Enterprise Edition. With SQL, when you buy your licenses for Enterprise Edition, you get everything. Distributed replay allows you to capture a workload on a production server, and replay it on another machine. This way changes in underlying schemas, support packs, or hardware changes can be tested under production conditions.10. PowerView -- You may have heard of this under the name "Project Crescent" it is a fairly powerful self-service BI toolkit that allows users to create mash ups of BI reports from all over the Enterprise.11. SQL Azure Enhancements -- These don't really go directly with the release of SQL 2012, but Microsoft is making some key enhancements to SQL Azure. Reporting Services for Azure will be available, along with backup to the Windows Azure data store, which is a huge enhancement. The maximum size of an Azure database is now up to 150G. Also Azure data sync allows a better hybrid model of cloud and on-premise solutions12. Big Data Support -- I saved the biggest for last, introduced at the PASS (Professional Association for SQL Server) conference last year, Microsoft announced a partnership with Hadoop provider Cloudera. One part of this involves MS releasing a ODBC driver for SQL Server that will run on a Linux platform. Additionally, Microsoft is building connectors for Hadoop, which is an extremely popular NoSQL platform. With this announcement, Microsoft has made a clear move into this very rapidly growing space.SQL 2012 is a big step forward for Microsoft -- the company is positioning itself to be a leader in availability and in the growing area of big data. As a database professional, I look forward to using SQL 2012 to bring new solutions to my clients.
Using SQL Server 2012 T-SQL New Features
IntroductionSQL Server 2012 “Denali” is the next major release of Microsoft database server. There are some new features that are added to T-SQL to make common tasks much easier. I will show how to use some of the new features in this article.
SequenceGenerating a sequence number, a.k.a. auto number, is a common task in an enterprise application. For a single table, you can specify identity field. But, if you want to have database wide sequential number, then you must devise something by yourself before SQL Server 2012. One solution to this problem is to create a table that has a numeric field can be used to store sequential number, then use SQL to increase it every time used one. In SQL Server 2012, we have a new solution - use Sequence.
Create Sequence
To create a Sequence in SQL Server 2012 is very simple. You can create it with SQL Server Management Studio or T-SQL.
1. Create Sequence with SQL Server Management StudioIn Object Explorer window of SQL Server Management Studio, there is a Sequences node under Database -> [Database Name] -> Programmability. You can right click on it to bring up context menu, and then choose New Sequence… to open the New Sequence window. In New Sequence window, you can define the new Sequence, like Sequence Name, Sequence schema, Data type, Precision, Start value, Increment by, etc. After entering all the required information, click OK to save it. The new Sequence will show up in Sequences node.
2. Create Sequence with T-SQLThe following T-SQL script is used to create a new Sequence:
Collapse | Copy Code
CREATE SEQUENCE DemoSequenceSTART WITH 1INCREMENT BY 1;
Use Sequence
The new NEXT VALUE FOR T-SQL keyword is used to get the next sequential number from a Sequence.
Collapse | Copy Code
SELECT VALUE FOR DemoSequence
One thing I want to mention in here is Sequence doesn’t support transaction, if you run this script:
Collapse | Copy Code
BEGIN TRANSELECT NEXT VALUE FOR dbo.DemoSequenceROLLBACK TRAN
You can see even the transaction is rolled back at the end. The NEXT VALUE FOR will still return the next sequential number. This behavior is consistent with identity field.
Page DataA common situation for displaying page is how to display large amount of data in DataGrid. Earlier, the programmer usually used the paging feature of DataGrid to handle this situation. Therefore, by choosing a different page number, different set of data are displayed on the screen. However, how to retrieve data from database is multiplicity. A developer could:
1. Retrieve all data from database, and then let DataGrid to only display the current page data.
2. Retrieve the current page data from database by using temp table.3. Retrieve the current page data from database by using ROW_NUMBER() function.
The SQL Server 2012 provided a new way to retrieve current page data from database. Collapse | Copy Code
SELECT *FROM CustomersORDER BY CustomerIDOFFSET 10 ROWSFETCH NEXT 10 ROWS ONLY;
The OFFSET keyword and FETCH NEXT keyword allow the developer to only retrieve certain range data from database. If you compare this script with ROW_NUMBER() function introduced in SQL Server 2008, you can see this script is shorter and more intuitive.
Collapse | Copy Code
SELECT *FROM (SELECT ROW_NUMBER() OVER(ORDER BY CustomerID) AS sequencenumber, *FROM Customers) AS TempTableWHERE sequencenumber > 10 and sequencenumber <= 20
Exception Handling
SQL Server 2005 introduced TRY CATCH block to handle exception in T-SQL. The TRY CATCH block is similar to whatever in C# language except you need always raise a new exception after catching it. There is no way to simply re-throw it.
A sample of T-SQL script with exception handling in SQL Server 2005:
Collapse | Copy Code
BEGIN TRYBEGIN TRANSACTION – Start the transaction
-- Delete the CustomerDELETE FROM CustomersWHERE EmployeeID = ‘CACTU’
-- Commit the changeCOMMIT TRANSACTION
END TRYBEGIN CATCH
-- There is an errorIF @@TRANCOUNT > 0
ROLLBACK TRANSACTION
-- Raise an error with the details of the exceptionDECLARE @ErrMsg nvarchar(4000), @ErrSeverity intSELECT @ErrMsg = ERROR_MESSAGE(),
@ErrSeverity = ERROR_SEVERITY()
RAISERROR(@ErrMsg, @ErrSeverity, 1)END CATCH
In SQL Server 2012, by using Throw keyword, the above script will be changed to this:
Collapse | Copy Code
BEGIN TRYBEGIN TRANSACTION -- Start the transaction
-- Delete the CustomerDELETE FROM CustomersWHERE EmployeeID = ‘CACTU’
-- Commit the changeCOMMIT TRANSACTION
END TRYBEGIN CATCH
-- There is an errorROLLBACK TRANSACTION
-- Re throw the exceptionTHROW
END CATCH
Also, you can use Throw to replace RAISERROR function:
Collapse | Copy Code
THROW 51000, ‘The record does not exist.’, 1;
Enhanced EXECUTE keywordThe EXECUTE keyword is used to execute a command string. The previous version SQL Server only has WITH RECOMPILE option to force new plan to be re-compiled. The SQL Server 2012 dramatically improved this part. The option part is like this right now.
Collapse | Copy Code
[ WITH <execute_option> [ ,…n ] ]
<execute_option>::={
RECOMPILE| { RESULT SETS UNDEFINED }| { RESULT SETS NONE }| { RESULT SETS ( <result_sets_definition> [,…n] ) }
Application sometimes needs more insight of the SQL script result set. In the past, you needed to write a complicated script to query system tables or views, e.g. sys.objects, to get all the information. In SQL Server 2012, the new system stored procedure sp_describe_first_set makes the work trivial.
Collapse | Copy Code
sp_describ_first_result_set @tsql = N’SELECT * FROM customers’
SummaryThere are more T-SQL new features in the upcoming SQL Server 2012. Majority of them are designed to improve development efficiency and reduce development effort.
New T-SQL features in SQL Server 2012 – OFFSET and FETCH –
Microsoft has decided in SQL Server 2012, that they will modify the ORDER BY clause and do
what MySQL has been doing for a long time – providing simple functions for paging result sets.
This comes in the form of OFFSET and FETCH.
Now, I’m not saying that this was previously not possible in SQL Server. There are solutions to
this problem in other versions of the product in the form of temp tables, ROW_NUMBER() and
TOP but I prefer OFFSET and FETCH to the others – it’s just simple!
I am using SQL Server 2012 Express and the AdventureWorks 2012 database for this
demonstration.
So lets look at some data and I have decided to query some of the fields from the
TransactionHistory table under the Production schema.
SELECT TOP 10
TransactionID
, ProductID
, TransactionDate
, Quantity
, ActualCost
FROM
Production.TransactionHistory;
This table contains approximately 133,500 rows – not a massive amount in today’s world but for the
purposes of this article, lets say I wanted to write queries to page through this data sorted by newest
transactions and I wanted to display 20 rows per page.
Using OFFSET and FETCH in SQL Server 2012So here is an example. Note that OFFSET and FETCH are added after the ORDER BY clause.01 SELECT
02 TransactionID
03 , ProductID
04 , TransactionDate
05 , Quantity
06 , ActualCost
07 FROM
08 Production.TransactionHistory
09 ORDER BY TransactionDate DESC
10 OFFSET 0 ROWS
11 FETCH NEXT 20 ROWS ONLY;
OFFSET provides a starting row from which to display the result set. FETCH instructs the query
to display the number of rows you want in your result set from the OFFSET point.
Note that NEXT or FIRST can be supplied for FETCH and are synonyms for ANSI
compatibility. You can also type ROW or ROWS, again they are synonyms for ANSI
compatibility.
So this is nice and easy, for the next page of results, the OFFSET value would be changed to 20
and then 40 etc.
OFFSET and FETCH can accept variables so for example:01 DECLARE @OffsetRows tinyint = 0
02 , @FetchRows tinyint = 20;
03 SELECT
04 TransactionID
05 , ProductID
06 , TransactionDate
07 , Quantity
08 , ActualCost
09 FROM
10 Production.TransactionHistory
11 ORDER BY TransactionDate DESC
12 OFFSET @OffsetRows ROWS
13 FETCH NEXT @FetchRows ROWS ONLY;
You can use expressions in OFFSET and FETCH:1 ORDER BY TransactionDate DESC
2 OFFSET @OffsetRows - 0 ROWS
3 FETCH NEXT @FetchRows - @OffsetRows + 1 ROWS ONLY;
And I really like this – plugging in a scalar sub queries:01 SELECT
02 TransactionID
03 , ProductID
04 , TransactionDate
05 , Quantity
06 , ActualCost
07 FROM
08 Production.TransactionHistory
09 ORDER BY TransactionDate DESC
10 OFFSET @OffsetRows ROWS
11 FETCH NEXT (SELECT 20) ROWS ONLY;
So imagine that (SELECT 20) was in fact reading a table somewhere in your system (SELECT
PageSize FROM PageSetting WHERE SiteID = 5) which controlled the number of rows to be
displayed for each query.
OFFSET and FETCH versus ROW_NUMBER()I’m not going to go into detail about all the methods of paging which have been employed in
previous versions of SQL Server and start drawing comparisons and conclusions over
performance (perhaps I will in a future post) but the one which immediately springs to mind as
an alternative to OFFSET and FETCH is ROW_NUMBER()
So a quick comparison between the two methods shows the following:
Using OFFSET and FETCH01 SELECT
02 TransactionID
03 , ProductID
04 , TransactionDate
05 , Quantity
06 , ActualCost
07 FROM
08 Production.TransactionHistory
09 ORDER BY TransactionDate DESC
10 OFFSET 0 ROWS
11 FETCH NEXT 20 ROWS ONLY
Using ROW_NUMBER() with CTE01 WITH Paging_CTE AS
02 (
03 SELECT
04 TransactionID
05 , ProductID
06 , TransactionDate
07 , Quantity
08 , ActualCost
09 , ROW_NUMBER() OVER (ORDER BY TransactionDate DESC) AS RowNumber
10 FROM
11 Production.TransactionHistory
12 )
13 SELECT
14 TransactionID
15 , ProductID
16 , TransactionDate
17 , Quantity
18 , ActualCost
19 FROM
20 Paging_CTE
21 WHERE RowNumber > 0 AND RowNumber <= 20
So what do you think? It’s certainly easier to write a query using OFFSET and FETCH as there
is less involved. There is one less column too because “RowNumber” is not needed for the
OFFSET and FETCH version.
If I were a betting man, I would say that the execution plans are different between the two
queries. So lets take a look.
Using OFFSET and FETCH…
Using ROW_NUMBER()…
There is certainly more going on in the second one right? As I wrote above, I’m not intending to
draw any conclusions on this because I am not doing any thorough testing here.
Finally, if you want to guarantee stable results in your OFFSET and FETCH paging solution
there are two things that you must implement.
1. You should ensure that the underlying data does not change and that involves running the queries inside
a transaction using either snapshot or serializable transaction isolation.
2. The ORDER BY clause needs to contain a column or combination of columns that are guaranteed to be
unique.
Top 10 new Features in SQL 2012
The release of Microsoft SQL Server 2012 brings a whole host of important changes to Microsoft's
enterprise data platform, including changes in the editions that Microsoft will offer as well as a new
licensing model. In addition, SQL Server 2012 introduces many performance, business intelligence (BI),
and development enhancements. Here's a rundown of the top 10 most important new features in SQL
Server 2012.
10. Simplified editions -- SQL Server 2012 will be delivered in three main editions: Enterprise, Business
Intelligence, and Standard. The Enterprise edition contains all of the product's features. The Business
Intelligence edition contains all of the BI capabilities but lacks some of the higher-end availability features.
The Standard edition provides basic relational, BI, and availability capabilities. Microsoft has retired the
Datacenter, Workgroup, and Standard for Small Business editions but will continue to provide the
Developer, Express, and Compact Editions. The Web edition will be offered only to web hosting providers
who have a Services Provider License Agreement (SLPA).
9. Processor core licensing model -- With SQL Server 2012, Microsoft has moved away from counting
sockets to a new core-based licensing model. The Enterprise edition can be licensed only per core. The
list price is $6,874 per core. The Business Intelligence edition is licensed only per server; it goes for
$8,592 per server. You must also purchase Client Access Licenses (CALs) per user. The CAL price has
Eric Hanson, Principal Program Manager Architect at Microsoft, talked about the decision in a recent
interview:
We wanted to build off of the success of SQL Server 2012 and, as with our well-received SQL Server
2008 R2 campaign, create a migration story that was more intuitive for our customers. We conducted several
usability studies and concluded that users don't care what year their software was released, and found it
easier to follow an upgrade path with simple, incremental release numbers."
Rock your data with SQL Server 2012 Parallel Data Warehouse (PDW) – What’s new?As I already stated out in my first post I want share some insights about the new SQL Server
2012 version of Parallel Data Warehouse. In this post I will talk about some new features as
well as architecture changes.
ARCHITECTURE UPDATE
The SQL Server 2012 version of PDW introduces some major architecture changes:
As show in the picture below the Landing Zone and the Backup node have been removed
from the appliance and there good reasons for. The standard sizing of these component
didn’t met most of the customer requirements and it was very hard to find a
configuration that meets 80% of PDW customers. So decision has been made to remove
these components and customers have now more flexibilities to size the ETL and the
This article describes the exciting new versions and features of the recently released Microsoft SQL Server 2012.
Since the introduction of SQL Server 7.0, Microsoft continues to make giant leaps in data analytics, data mining, data
retrieval performance, and high-availability; thus, earning a significant spot in the Gartner quadrant for business
intelligence (BI) platforms.
SQL Server overtakes IBM DB2 and claims #2 spot for DBMS revenue.
Lowest total cost of ownership when compared to other DBMS vendors.
SQL Server reliably manages the data for the largest retail project of 8,000 stores.
PowerPivot was voted one of eWeek’s Top 10 technologies of 2010.
SQL Server delivers 99.9999% uptime availability.
This article will list and describe the editions, key features, and will review licensing.
Editions
SQL Server 2012 Enterprise (EE) Can utilize as many core processors and memory as are supported by the
host Windows Operating system (OS). Includes support for all of the advanced availability (“AlwaysOn”) and
advanced BI features. Includes advanced analysis features such as: PowerPivot, Power View,
Master Data Services, and advanced auditing. Includes new data management features such as: Transparent data
encryption and “ColumnStore” index. Licensed per core which is different compared to the SQL Server 2008.
SQL Server 2012 Standard
Supports up to 16 core processors and up to 64GB of memory. Does not include support for any of the advanced features listed under
Enterprise. Licensed per core or server Support for two-node “AlwaysOn” failover
SQL Server 2012 Business Intelligence
A unique edition to SQL Server 2012. Supports up to 16 core processors and up to 64GB of memory. For SQL Server Analysis Services (SSAS) and SQL Server Reporting
Services (SSRS), this edition can use as many cores supported by the host Windows server OS.
Includes all of the BI features listed under Enterprise including: Power View and PowerPivot.
SQL Server 2012 Express and LocalDB
Free licensing Limited support for one processor and 1 GB of memory. Designed to work with lightweight client applications Runs as a user process and not as a Windows service.
SQL Server 2012 Web and Developer
The Developer edition includes all of the features of EE Licensed per developer and as with previous versions, cannot be used to
support production installations. The Web edition is licensed to the web hosting firms with service provider
license agreements.Key Features
Just a few of the new features listed here:
AlwaysOn – It is often heard that IT department directors are interested in high availability, however they are reluctant to buy additional hardware to support SQL Server clustering and Database Mirroring does not allow for immediate use of mirrored databases. “AlwaysOn” failover eliminates the need for idle hardware and this feature allows for the utilization of a “Reporting” server to provide failover support for the Dynamics AX Online Transaction processing (OLTP) database. For more information, please refer to this link:http://www.microsoft.com/sqlserver/en/us/solutions-technologies/mission-critical-operations/SQL-Server-2012-high-
availability.aspx
Columnstore Index – A new type of index to greatly improve reporting performance. Creating a ColumnStore increases reporting efficiency by storing table columns commonly used in reports in a separate set of disk pages. When compared to storing several rows per page, this makes disk access much faster. For more information, please refer to this whitepaper:http://www.sqlserver-training.com/what-is-columnstore-index-in-sql-server/-
Database Recovery Simplified – Using the Database Recovery Advisor, a visual timeline can be viewed by the Database Administrator (DBA) which will show the backup history and helps the DBA identify which backups are required to get a database recovered to a specific point. For more information, please refer to this link:http://www.mssqltips.com/sqlservertip/2618/point-in-time-recovery-using-new-timeline-feature-in-sql-server-2012
PowerPivot - To download Microsoft SQL Server 2012 PowerPivot for Excel 2010, please refer to this link:http://www.microsoft.com/download/en/details.aspx?id=29074
Power View (SSRS)
Integrated with Microsoft SharePoint, Power View allows users to create and view powerful interactive reports using a
few clicks of the mouse. These graphics can easily be imported into PowerPoint to create highly effective business
How to manage SQL Server transaction log files. Tips on maximizing performance and scalability of Dynamics 2012. Dynamics AX 2012 support for telephony systems. Dynamics AX 2012 integration tools.