Hi Friends,

Microsoft introduced so many new features and improvements with SQL Server 2014. In addition to these features, one of the improvement provided in SQL Server 2014 is about SELECT INTO statement. The SELECT INTO  generally used to copy the data from one table and inserts that data into a new table.

Before SQL Server 2014, SELECT INTO statement was single threaded operation and take long time. From SQL Server 2014 onward, SELECT INTO is multi-threaded operation and gives is much faster processing. Here, multi-threaded means this operation can execute using parallelism. Here, we will test the processing of SELECT INTO statement for both the cases.

Here, I am using AdventureWorksDW database with SQL Server 2014. To check the execution behaviour of SELECT INTO statement on SQL Server 2012, I’ll change the compatibility level of the database to SQL Server 2012 as shown below:

Execute below SELECT INTO statement:

Execution Time Details are mention below:

SQL Server Execution Times:

CPU time = 235 ms,  elapsed time = 246 ms.

SQL Server parse and compile time:

CPU time = 0 ms, elapsed time = 0 ms.

SELECT INTO Statement

Now try to change the compatibility level to 120, which is for SQL Server 2014:

Execute below SELECT INTO statement:

Execution Time Details are mention below:

SQL Server Execution Times:

CPU time = 171 ms,  elapsed time = 74 ms.

SQL Server parse and compile time:

CPU time = 0 ms, elapsed time = 0 ms.

select-into-statement2

The changes those you can notice here are:

  • SQL Server 2014, started using parallelism for SELECT INTO execution.
  • Execution time is much faster with parallelism compare to single threaded operation.

HAPPY LEARNING!

Thanks & Regards:
Prince Rastogi

Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook

Follow Prince Rastogi on Twitter | Follow Prince Rastogi on FaceBook