
This means that if the inserts fail, they will all be rolled back, but the new (empty) table will remain. The SELECT.INTO statement operates in two parts - the new table is created, and then rows are inserted. See "Creating an identity column using the IDENTITY function" in the Examples section below. If an identity column is required in the new table but such a column is not available, or you want a seed or increment value that is different than the source identity column, define the column in the select list using the IDENTITY function. If any one of these conditions is true, the column is created NOT NULL instead of inheriting the IDENTITY property. The identity column is from a remote data source. The identity column is part of an expression. The identity column is listed more than one time in the select list. Multiple SELECT statements are joined by using UNION. When an existing identity column is selected into a new table, the new column inherits the IDENTITY property, unless one of the following conditions is true: If a FILESTREAM BLOB exceeds this value, error 7119 is raised and the statement is stopped. Without the FILESTREAM attribute, the varbinary(max) data type has a limitation of 2 GB. FILESTREAM BLOBs are copied and stored in the new table as varbinary(max) BLOBs. The FILESTREAM attribute does not transfer to the new table. The filegroup specified should exist on the database else the SQL Server engine throws an error.Īpplies to: SQL Server 2016 (13.x) SP2 and later. Specifies the name of the filegroup in which new table will be created. Alternatively, you can use the OPENQUERY function or the OPENDATASOURCE function in the FROM clause to specify the remote data source. object in the FROM clause of the SELECT statement. To create new_table from a remote source table, specify the source table using a four-part name in the form linked_server. You cannot create new_table on a remote server however, you can populate new_table from a remote data source. To create the table in another database on the same instance of SQL Server, specify new_table as a fully qualified name in the form _name. The IDENTITY property of a column is transferred except under the conditions defined in "Working with Identity Columns" in the Remarks section. Each column in new_table has the same name, data type, nullability, and value as the corresponding expression in the select list. The columns in new_table are created in the order specified by the select list. The format of new_table is determined by evaluating the expressions in the select list.

Specifies the name of a new table to be created, based on the columns in the select list and the rows chosen from the data source. To view Transact-SQL syntax for SQL Server 2014 and earlier, see Previous versions documentation.
