Selecting Contents from one table into another (Resolved)

  • Hello community...,

    I seem to be having one of those senior moments this morning :w00t:

    I wanted to select everything from table A and place into a new table b. Here's what I thought would work, but failed.

    SELECT * FROM TABLE_A

    INTO TABLE BK_TABLE_B

    But I receive:

    Msg 156, Level 15, State 1, Line 2

    Incorrect syntax near the keyword 'INTO'.

    ...:-P...

    Once the Senior Moment was over. I figured it out. (I'm going to go ahead and post it anyways because it might be helpful for other newbie's...

    SELECT * INTO BK_TABLE_B

    FROM TABLE_A

    That made a completely new table in the database housing all of the data from TABLE_A so that once I run the UPDATE statement and the customer says, "That's not what I wanted even though I told you it was and I failed to listen to your caution about data manipulation..." (it could happen :hehe: ) I could restore the data with a statement like:

    INSERT INTO DME_CHARGE_RULE

    SELECT * FROM BK_DME_CHARGE_RULE

    Hope this helps someone! Have a wonderful day!:alien:

  • Doctork11 (4/2/2010)


    SELECT * INTO BK_TABLE_B FROM TABLE_A

    really?

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Viewing 2 posts - 1 through 1 (of 1 total)

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