SQL statement objective:
When creating a temporary table, create a column of seeds automatically added. This involves copying data across databases. Here, the database uses SQL SERVER 2000.
Select into statement Syntax: SELECT column_name (s) INTO newtable [IN externaldatabase] FROM source
Incorrect SQL statement: SELECT IDENTITY (INT, 1, 1) AS [NewID], * INTO # tBranch FROM test. dbo. TB_test ts
The error message is as follows (fid is a field of TB_test): you cannot use the select into statement to add an ID column to the '# tBranch' table, this table already contains the 'fid' column that inherits the identity attribute '.
But there are no errors in the following two statements:
-- The following statement indicates
Cross-DatabaseHowever
Remove auto-increment ColumnsExecution is normal SELECT * INTO # tBranch FROM test. dbo. TB_test ts
-- The following statement indicatesWithin the same databaseExecution is normal. select identity (INT, 1, 1) AS [NewID], * INTO # tBranch FROM TB_test
Summary:
I don't know whether it is a database BUG or I don't know enough about the database. I hope you can answer this question.