T-SQL

Specifying FILEGROUP in SELECT * INTO

SQL Server 2017 and SP2 for SQL 2016 bring a small enhancement of SELECT .. INTO clause which offers more possibilities on how to solve some DBA head-scratching situations. It’s possible to specify FILEGROUP where the new table will be created. Till now it was only in the PRIMARY filegroup which brings a lot of issues in case the database is divided into more filegroups and primary filegroup stores metadata only with minimal sizing. Running SELECT .. INTO can be used as another option on how to move data between data files and groups. Same for performance optimization like copying data for further processing to filegroup residing on SSD optimized storage.

Syntax:

SELECT *
	INTO dbo.SampleTable_Copy
		ON OtherFilegoup
FROM dbo.SampleTable
GO

More detail can be found in MSDN or simple demonstration at mssqltips.com.

Leave a Reply

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