Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8689545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:40:25+00:00 2026-06-12T23:40:25+00:00

I want to transfer all data from one table into another with the following

  • 0

I want to transfer all data from one table into another with the following code:

INSERT INTO tblpremier 
   SELECT * INTO #TempTable
   FROM dbo.IntermediateTable

ALTER TABLE #TempTable
DROP COLUMN id

SELECT * FROM #TempTable

And I get an error

Incorrect syntax near the keyword ‘INTO’

at the second line of this code. Any help?.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:40:26+00:00Added an answer on June 12, 2026 at 11:40 pm

    What you’ve written doesn’t make any sense. The first “statement” is this:

    INSERT INTO tblpremier 
    SELECT * INTO #TempTable
    FROM dbo.IntermediateTable
    

    Now are you inserting into #temptable, or tblpremier? I’m guessing you wanted to perform all these operations and then insert into tblpremier – in which case split it into separate statements. I’m guessing you wanted to do:

    SELECT * INTO #TempTable
    FROM dbo.IntermediateTable
    
    ALTER TABLE #TempTable
    DROP COLUMN id
    
    INSERT INTO tblpremier
    SELECT * FROM #TempTable
    

    But rather than need #Temptable which is the same as IntermediateTable minus the ID column, why not just select the correct columns you need from IntermediateTable in the first place rather than using *?

    Edit:

    Here’s what I meant. Write the insert statement so you’ve got all the column names specified, and don’t include the ID column. You’ll get all new ID numbers on the copy of the table.

    INSERT INTO tblpremier (column1, column2, column3, ...)
    SELECT column1, column2, column3, ...
    FROM IntermediateTable
    

    However, if you wanted to to keep the same ID numbers in the copy of the table, and the columns are in the same order on both intermediate table and tblpremier, then you could write:

    SET IDENTITY_INSERT tblpremier ON
    
    INSERT INTO tblpremier
    SELECT * 
    FROM IntermediateTable
    
    SET IDENTITY_INSERT tblpremier OFF
    

    But you would still need to watch out for trying to insert duplicate IDs if tblpremier isn’t empty at first.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to transfer data from one table to another. The second table got
I'm creating an intent to transfer data from one activity to another like this
During last time I made many integrations (data transfer from one place to another,
I want to transfer one asp.net page form values to another page when i
I want to transfer data(21M rows) from mysql database to DynamoDB. I am using
I am doing webparts in sharepoint and I want to transfer the data from
Possible Duplicate: transfer data from javascript popup multiline textbox to a select control I
We have manage to export data from our mysql table into a .txt file.
I want to get data from a DMA enabled, PCIe hardware device into user-space
I have a problem when I want to transfer data from Excel to dataGridView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.