In the first case, append the data from the a database. dbo.a table to the B database. DBO.B table (condition: B table is already created in the B database )
Inert into B database. dbo.b table
SELECT * from a database. dbo.a table [WHERE condition]
This T-SQL statement will have an exception if you use a column list and Identity_insert is on, you can specify an explicit value for the Identity column in table ' B database. dbo.b table '.
Cause: B database. A column in the DBO.B table is set to autogrow (typically the primary key ID).
Solution: Turn the * into a specified [column name] and remove the column that automatically grows.
Second case: Copy the data from the a database. dbo.a table to the B database. DBO.B table (condition: B table is not created in the B database or table with the same name )
SELECT * into B database. dbo.b table from a database. dbo.a table [WHERE condition]
After executing this statement, the B database will be created with a database. DBO.A table-like structure B. Table B created from this statement does not have a primary key.
How to copy a table from one database to a table in another database