Saturday , December 21 2024

SELECT INTO On Filegroup

Tables created with SELECT INTO prior to SQL Server 2017 could not be created on a filegroup other than the PRIMARY filegroup. Now we can create the tables we created with SELECT INTO on any filegorup.

Let us clarify the subject by making an example.

First we create a new filegroup named FG in the database. For more information, read the article “How To Create a Database On SQL Server“.

You can then use the following script to create an existing table on the desired filegroup.

You should write the name of the table you want to create instead of “newtable”, the name of the table you want to transfer instead of “oldtable”, and the new filegroup name instead of “FG”.

Loading

About dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

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