SQL SELECT INTO statement usage Problems

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.