Skip to content

SQL Server 2014 Tips: Create indexes directly via CREATE TABLE

This week, I discovered a new enhancement which is not hidden but not really visible in SQL Server 2014. Among Hekaton and other new features in SQL Server 2014, a little option appears in table creation.8-O
On the msdn website, we can see a new section in the “CREATE TABLE” code:

Create_table_index_01.png

 

Create_table_index_02.png

We can directly create an index in the “CREATE TABLE” query. Ok, then let’s go!

In my example, I create a diver table with a default clustered index on a primary key (DiverId) and 2 other non-clustered indexes on Diving Level (OWD, AOWD, Level 1, Level 2,…) and Diving Organization (PADI, CCMAS, SSI,…).

Prior to SQL Server 2014, you create indexes after setting up the table like this.

Create_table_index_03.png

We need to have 3 instructions to create a table and 2 non-clustered indexes.

In SQL 2014, it is very easy with just one query:

Create_table_index_04.png

I’m very happy to share new features with you that are not necessarily in the light!:-D
You will find the MSDN “CREATE TABLE” reference for SQL Server 2014 here.

Let’s work together

Ready to operate at
the next level?

Tell us about your challenge. We’ll bring the depth, the expertise, and the Swiss precision.

Stéphane Haby

Stéphane Haby

Stéphane Haby has more than 20 years of experience in Microsoft solutions, specializing in the installation, migration, best practices, and performance analysis of Microsoft SQL Server, as well as Microsoft Business Intelligence solutions (SharePoint, Office) and .NET development for the banking sector. A former Microsoft Most Valuable Professional (MVP) and early adopter of Microsoft Team System in France, he has authored several technical articles. He holds Microsoft Certified Solutions Associate (MCSA) and Expert (MCSE) for SQL Server, MCTS, MCITP for SQL Server 2008, and ITIL V3 Foundation certifications. His industry experience covers chemicals and pharma, banking, and financial services.View Author posts

182 posts since April 2011

Leave a Comment

Your email address will not be published. Required fields are marked *