Archive for March, 2016

My whitepaper published on – Top 8 features of SQL Server 2016

March 14, 2016 Leave a comment

I am super excited to announce the availability of my Whitepaper at Microsoft IT Showcase on:

Microsoft IT looks at the top eight features of SQL Server 2016

Microsoft IT Showcase - SQL Server 2016 Top-8 features

Download : Word | PDF


1. In-Memory OLTP helps ESBI meet their users’ business requirements for increased agility.

2. Columnstore Indexes reduce the amount of time it takes to run and render SRSS reporting data.

3. Temporal data reduces the amount of support tickets received from the field due to inaccurate data.

4. Row-Level Security provides a more reliable and standardized method to easily control which users can access data.

5. Dynamic Data Masking helps limit exposure of sensitive data, preventing users who should not have access to the data from viewing it.

6. Query Store provides better insight into the performance differences caused by changes in query plans.

7. Active Query Statistics allows a view of active query execution plans and helps identify and fix blocking issues while queries are running.

8. SQL Stretch Database helps improve performance to frequently used data while preserving access to archived data.

Download : Word | PDF

Please check my other posts on SQL Server 2016

SQL Server on Linux – Microsoft announcement

March 12, 2016 Leave a comment


Scott Guthrie, Executive Vice President, Cloud and Enterprise Group, Microsoft on March 7, 2016 announced plans to bring SQL Server to Linux. He mentioned that this will enable SQL Server to deliver a consistent data platform across Windows Server and Linux, as well as on-premises and cloud, targeting the availability by mid-2017.

You can sign up for a Private preview here.

Recently in a Data Driven event Shawn Bice, General Manager, Database Systems Group, Microsoft showcased the capabilities and new features of SQL Server 2016. While demonstrating he gave a glimpse of SQL Server preview version running on Linux, and you can see the version in the snapshot below:

Microsoft SQL Server (Preview) – 13.0.8000.6 (X64)
Feb 24 2016 22:03:46 2015.0130.8000.06
Copyright (c) Microsoft Corporation
on Linux (Ubuntu 15.10)

SQL on Linux

Well I’m very excited and looking forward to download the SQL Server Linux preview and do some hands on.

Check more at

Categories: Linux, Microsoft Tags:

New in-built Table-Valued Function STRING_SPLIT() in SQL Server 2016 – to split strings

March 10, 2016 5 comments

Till now it was bit tricky to split a Sentence or CSV String to multiple values or rows, and we used different logic to do the same.

In my [previous post] I blogged similar logic to Split a String and Combine back by using some XML syntax.

In SQL Server 2016 this has been made simpler by using a new function STRING_SPLIT(), let’s see this with a simple example:

SELECT * FROM STRING_SPLIT('My name is Manoj Pandey', ' ')

This will split all the words in the sentence separated by a whitespace in different rows:


Here is the syntax for the same:

STRING_SPLIT ( string , separator )

Please note: that the separator should be a single character expression, so this should not be an empty string, like:

SELECT * FROM STRING_SPLIT('My name is Manoj Pandey', '')

Will result into an error:

Msg 214, Level 16, State 11, Line 3
Procedure expects parameter ‘separator’ of type ‘nchar(1)/nvarchar(1)’.


–> Let’s check one more example:

We have a comma separated Cities list for each State as a row in a table:

CREATE TABLE #tempCityState (
	[State] VARCHAR(5), 
	[Cities] VARCHAR(50)

INSERT INTO #tempCityState
SELECT 'AK', 'Nashville,Wynne'
SELECT 'CA', 'Fremont,Hanford,Los Anggeles'
SELECT 'CO', 'Aspen,Denver,Teluride,Vail'

Now, lets just use the simple function STRING_SPLIT() with CROSS APPLY operator, like:

SELECT [State], value
FROM #tempCityState

Will give you following output:


–> And if I compare the performance of this function with the earlier approach I mentioned in my [previous post]:

Run both the queries by enabling Actual Execution plan (Ctrl + M):

SELECT [State], value
FROM #tempCityState

SELECT A.[State], Split.a.value('.', 'VARCHAR(100)') AS City
FROM (SELECT [State], CAST ('<M>' + REPLACE([Cities], ',', '</M><M>') + '</M>' AS XML) AS String
    FROM  #tempCityState) AS A
CROSS APPLY String.nodes ('/M') AS Split(a)

I can see that the STRING_SPLIT() gives me better performance compared to the other:

“SELECT *” or “SELECT 1” or “SELECT column_Name” while using EXISTS() – what shoud I use? – MSDN TSQL forum

March 9, 2016 2 comments

–> Question:

Please tell me which method is good and fast

1) select a,b from t1 where exists (select 1 from t2 where t1.t1id = t2.t1id )

2) select a,b from t1 where exists (select * from t2 where t1.t1id = t2.t1id )

3) select a,b from t1 where exists (select t2.t1id from t2 where t1.t1id = t2.t1id )

–> My Answer:

It does not matter what you use with SELECT inside EXISTS () statement

Because, as soon as EXIST() statement get one row it breaks/exits, and it just ignores the column’s list in SELECT clause.

You can check by this by simple example:

select a,b from t1 where exists (select 1/0 from t2 where t1.t1id = t2.t1id)

The “SELECT 1/0” ideally should give divide-by-zero error, but here inside EXISTS() it does not.

So, I use “SELECT *” happily within EXISTS() clause 🙂 like:

select a,b from t1 where exists (select * from t2 where t1.t1id = t2.t1id)


–> Answer By CELKO:

The optimizer is smart enough to figure out the exist () predicates are the same. However, this was not always true in early versions of SQL. Oracle originally liked using a constant or an actual column name, because it is it did not have a good optimizer. The original SQL–86 specs implied (but did not require) that the table be materialized. We really were not very smart in those days.

Today, for stylistic reasons and to make searching easier, we prefer exists (SELECT * FROM ..) In code. This makes it easier to locate the exist predicates with this text search, and shows that the operation is performed on an entire table rather than a single column.

SQL is much like a natural language; you can be understood if you speak with poor grammar, but people respect you more if you have good grammar and style.

Ref link.

SQL Server 2016 RC0, first Release Candidate is available for download

March 8, 2016 1 comment

Microsoft (on 7-March-2015) announced the first SQL Server 2016 release candidate, SQL Server 2016 Release Candidate (RC) 0. With this release SQL Server adds rich set of capabilities, including Real-time Operational Analytics, rich Visualizations on mobile devices, built-in Advanced Analytics, new advanced Security technologies, and new Hybrid scenarios allowing you to securely Stretch data to the cloud.

[Register and Download the CTP 3.3 Evaluation version (180 days) here]

–> Direct download link (~2.6 GB):

– Download the single ISO: SQLServer2016RC0-x64-ENU.iso

– Or download both EXE & BOX files:
   – Box file
   – EXE file SQLServer2016-x64-ENU.exe

– Download SSMS: SSMS-Full-Setup.exe

–> Check version and SQL build:

select @@version

Microsoft SQL Server 2016 (RC0) – 13.0.1100.288 (X64)
Feb 29 2016 23:19:56
Copyright (c) Microsoft Corporation
Enterprise Evaluation Edition (64-bit) on Windows 10 Enterprise 6.3 (Build 10586: )

Please Note: Management Studio (SSMS) is no longer bundled with the ISO or CAB files, and will need to be installed separately, link mentioned above for RC0.

–> The RC 0 has some awesome new features:

1. Database scoped configuration: a new database level object that holds optional configuration values that affect the behavior of the application code at the database level. This statement modifies the default SQL Server 2016 Database Engine behavior for a particular database. A generic mechanism for creating database configuration(s) at creation time is not provided. These options are:
   – Clear procedure cache.
   – Set the MAXDOP parameter to an arbitrary value (1,2, …) for the primary database based on what works best for that particular database and set a different value (e.g. 0) for all secondary database used (e.g. for reporting queries).
   – Set the query optimizer cardinality estimation model independent of the database to compatibility level.
   – Enable or disable parameter sniffing at the database level.
   – Enable or disable query optimization hotfixes at the database level.

2. PolyBase enhancements includes support for:
   – The latest Cloudera distribution CDH5.5 on Linux.
   – Public containers and blobs in Azure blob storage.

3. In-Memory OLTP enhancements includes:
   – Parallel scan of non-clustered indexes.
   – Reduced downtime during upgrade.
   – Built-in function @@SPID is now supported natively compiled T-SQL modules and in constraints on memory-optimized tables
   – Log-optimized and parallel ALTER (ALTER TABLE operations now run in parallel).

4. STRING_SPLIT() and STRING_ESCAPE() function, new in-built Table-Valued Functions:
   – STRING_SPLIT, Splits input character expression by specified separator and outputs result as a table.
   – STRING_ESCAPE, Escapes special characters in texts and returns text with escaped characters.

5. Support for UTF-8 data to export and import.
   – Data stored in a UTF-8 encoded file can now be imported into SQL Server and exported from SQL Server into a UTF-8 encoded file, using BCP utility, BULK INSERT and OPENROWSET.

6. JSON_MODIFY() new function:
   – To update the value of a property in a JSON string and return the updated JSON string.

7. Stretch Database enhancements:
   – New version of Stretch Database on Azure that supports 60 TB of data
   – Azure Active Directory authentication, The option to use a federated service account for SQL Server to communicate with the remote Azure SQL Database server when certain conditions are true no longer requires a trace flag.

8. ColumnStore Index enhancements:
   – Compression delay. This new option minimizes the impact of the transactional workload on real-time operational analytics.
   – GROUP BY performance enhancement, aggregate pushdown for GROUP BY clause when run against a nonclustered columnstore index.
   – New alter table option, now you can create a columnstore index on an existing memory-optimized table.

9. SQL Server Management Tools (SSMS): SQL Server Management Tools is no longer installed from the main feature tree, as mentioned above.

–> Few more enhancements in other areas:

1. AlwaysOn Availability Groups add support for:
   – Distributed Availability Groups.
   – Streaming seeding of replicas.

2. SSAS (Analysis Services) add support for :
   – Display folders in Analysis Services.
   – PowerShell support for Tabular models.
   – SSIS support for Tabular models.
   – Tabular Object model for Tabular models.
   – more at Analysis Services blog.

3. SSRS (Reporting Services) support for:
   – Subscribe to reports to receive them in your email inbox, download, rename, move, and delete reports and other catalog items.
   – Manage shared datasets.
   – Manage data caching and refresh.
   – Create “linked” reports with different default parameter values.
   – Pin to a dashboard in a group when pinning a report chart, gauge, map, or image to a Power BI dashboard.
   – Choose the currency for monetary values when creating a KPI or mobile report.
   – more at Reporting Services blog.

4. SQL Server Integration Services (SSIS)
   – SSIS Projects in Visual Studio SQL Server Data Tools (SSDT) can now target 2012, 2014 and 2016 versions of SQL Server by switching a project level property between 2012, 2014 and 2016 SQL server.
   – SSIS now supports setting a server wide customized logging level.
   – The SSIS HDFS connector now supports the ORC file format, in addition to CSV and Avro.
   – more at Integration Services blog.

I’ve covered very few and important points here, you can check all the updates here in [SQL Server blog for RC 0] with details.

For all these new features released in SQL Server 2016, check my blog posts here.

So, download the Preview today and start playing with the new features and plan your DB migration/upgrade.

SQL Server 2016 CTP2 Install

Do check & Like my FB Page.