locked
cant use select into statement RRS feed

  • Question

  • User-583959464 posted

    my sql server management studio v17.9 version doesn't support the following sql and tableB table structure is same as tableA.

    select * into tableB from tableA

    it throws error "there is already an object named 'tableA' in the database.

    Monday, May 31, 2021 3:01 AM

All replies

  • User452040443 posted

    Try to remove the table before:

    drop table tableB;
    select * into tableB from tableA

    Hope this help

    Monday, May 31, 2021 12:23 PM
  • User1535942433 posted

    Hi 20141113,

    When I run the sql query "select * into tableB from tableA",it throws error "there is already an object named 'tableB".

    When you run the sql query,it will create a new tableB. However,it already have a tableB you have created.So,there are solutions:

    1.drop the tableB

    drop table tableB;
    select * into tableB from tableA

    2. insert contents from tableA

    INSERT INTO TableB SELECT * FROM TableA
    SELECT * FROM dbo.TableB

    Best regards

    Yijing Sun

    Tuesday, June 1, 2021 2:20 AM