I have a database DocData size with 8 GB. I want to move three tables form DocData to another database DocData2 with out using import export wizard and identity columns in these tables. I want to move it using a script and copy data with identity column. One of the tables size is 7 GB.
I am using this query
CREATE TABLE [DocData2].[dbo].DocumentPages AS
SELECT * FROM [DocData].[dbo].[DocumentPages]
but I am getting the following error.
Incorrect syntax near the keyword 'SELECT'.
FROM BOL
SET IDENTITY_INSERT [ database_name . [ schema_name ] . ] table ON
do inserts here
SET IDENTITY_INSERT [ database_name . [ schema_name ] . ] table OFF
You need to run the following statement.
Assumptions:
DocumentPages doesn't already exist in your destination database DocData2Script:
SELECT *
INTO [DocData2].[dbo].[DocumentPages]
FROM [DocData].[dbo].[DocumentPages]
Your Issue:
You cannot create tables using the script in the question. CREATE TABLE doesn't have any option to accept SELECT output to create a new table in such manner.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With