INSERT INTO - Help - "invalid object name"

  • I am using SQL Server 2000 (Developer's Edition), and have attempted to copy one record from Table A to Table B using the "INSERT INTO" syntax. I keep getting a pop-up menu that says "invalid object name." For some "odd reason," it is not recognizing one of the tables (I believe that is the problem - I could be wrong on the interpretation of the error message of "invalid object name").

    Would someone please provide me the full and complete statement to copy one record from Table A to Table B using INSERT INTO, or any other T-SQL statement.

    Thank you.

    Roy A. Day (royaday@hotmail.com)

  • Is TABLE A abd TABLE B both owned by DBO or is it possible they are owned by a user name. The best ways is to check in EM and look at the owner of both. If one or more is not owned by DBO then you will have to use OWNERNAME.TABLENAME to work with or us sp_changeobjectowner to change to dbo (see BOL).

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • quote:


    Is TABLE A abd TABLE B both owned by DBO or is it possible they are owned by a user name. The best ways is to check in EM and look at the owner of both. If one or more is not owned by DBO then you will have to use OWNERNAME.TABLENAME to work with or us sp_changeobjectowner to change to dbo (see BOL).

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)


  • quote:


    Is TABLE A abd TABLE B both owned by DBO or is it possible they are owned by a user name. The best ways is to check in EM and look at the owner of both. If one or more is not owned by DBO then you will have to use OWNERNAME.TABLENAME to work with or us sp_changeobjectowner to change to dbo (see BOL).

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)


    I am using "dbo" as confirmed on "EM." Roy A. Day (royaday@hotmail.com)

    NOTE: I incorrectly sent a one reply with no comment - I am learning this "system."

  • One thing I just oayed attention to is you stated pop-up menu???? which I have not seen in QA. Where are you doing this, what is the full test of the message including dialog title and what is the query? Also have you broke the query into pieces to test against each DB to make sure it is not the way you make your references?

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • quote:


    One thing I just oayed attention to is you stated pop-up menu???? which I have not seen in QA. Where are you doing this, what is the full test of the message including dialog title and what is the query? Also have you broke the query into pieces to test against each DB to make sure it is not the way you make your references?

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)


    My error - on the QA there is no pop-up menu (haste makes waste). On the QA screen, I receive a message on the message split screen that says: invalid object name, and the associated staement "server:msg 208, level 16, line1." Before we exchange any further emails, would you please provide me the "full and complete" T-SQL staement for INSERT INTO pertaining to copying a record from table A to table B (or use any other T-SQL statement besides INSRT INTO).

    Roy A. Day (royaday@hotmail.com)

  • Boy I need to learn to read complete messages, oops.

    INSERT INTO targettable (targetcol1, targetcol2, etc) SELECT origincol1, origincol2, etc FROM origintable (Any where clause you need against the origintable)

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • quote:


    Boy I need to learn to read complete messages, oops.

    INSERT INTO targettable (targetcol1, targetcol2, etc) SELECT origincol1, origincol2, etc FROM origintable (Any where clause you need against the origintable)

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)


    My T-SQL statement is the same as yours, and I receive the same error message "invalid object name" and "msg 208." I believe it is a path issue for the table, but all the tables are listed in the database file in the EM. I believe something is preventing the consummation of the path to the table. Is there any othe T-SQL statement I can use to accomplish the same task?

    Roy A. Day (royaday@hotmail.com)

  • The target table must be already exist before you run the insert into statement.

    Or you can run select * into targettable from originaltable if the target table hasn't been created yet.

  • If it exists then double check you didn't typo and are not missing a ( or ) where it should be. If the table name is actually number then you have to qualify by using [aroundit].

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • quote:


    If it exists then double check you didn't typo and are not missing a ( or ) where it should be. If the table name is actually number then you have to qualify by using [aroundit].

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)


    I already have the target table establihsed, and the name are characters. I checked my typing, and did not see any typos. Any other suggestions?

    Roy A. Day (royaday@hotmail.com)

  • quote:


    The target table must be already exist before you run the insert into statement.

    Or you can run select * into targettable from originaltable if the target table hasn't been created yet.


    I already have the target table establihsed, and the name are characters. I checked my typing, and did not see any typos. Any other suggestions?

    Roy A. Day (royaday@hotmail.com)

  • Try SELECT COUNT(*) FROM TABLEB and SELECT COUNT(*) FROM TABLEA and see if either gives you an invalid object return, that should narrow which it is.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • Try either delete or rename the target table and run select * into targettable from originaltable.

  • Hi

    Try to put brackets [ and ] around your table name. If the name contains spaces or is a special word, this error may occur.

    INSERT INTO [dstTable] (col1, col2, ...) SELECT col1, col2, ... FROM [dstTable]...

    Best regards

    el.c.

    myLittleTools.net :: web-based applications

    http://www.mylittletools.net


    myLittleTools.net :: web-based applications
    http://www.mylittletools.net

Viewing 15 posts - 1 through 15 (of 22 total)

You must be logged in to reply to this topic. Login to reply