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

  • SEARCH
  • Home
  • 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 44811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:42:38+00:00 2026-05-10T15:42:38+00:00

I have a temp table with the exact structure of a concrete table T

  • 0

I have a temp table with the exact structure of a concrete table T. It was created like this:

select top 0 * into #tmp from T 

After processing and filling in content into #tmp, I want to copy the content back to T like this:

insert into T select * from #tmp 

This is okay as long as T doesn’t have identity column, but in my case it does. Is there any way I can ignore the auto-increment identity column from #tmp when I copy to T? My motivation is to avoid having to spell out every column name in the Insert Into list.

EDIT: toggling identity_insert wouldn’t work because the pkeys in #tmp may collide with those in T if rows were inserted into T outside of my script, that’s if #tmp has auto-incremented the pkey to sync with T’s in the first place.

  • 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. 2026-05-10T15:42:39+00:00Added an answer on May 10, 2026 at 3:42 pm

    As identity will be generated during insert anyway, could you simply remove this column from #tmp before inserting the data back to T?

    alter table #tmp drop column id 

    UPD: Here’s an example I’ve tested in SQL Server 2008:

    create table T(ID int identity(1,1) not null, Value nvarchar(50)) insert into T (Value) values (N'Hello T!') select top 0 * into #tmp from T alter table #tmp drop column ID insert into #tmp (Value) values (N'Hello #tmp') insert into T select * from #tmp drop table #tmp select * from T drop table T 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a temp table set up like this: Type Rate TotalCost ---- ----
I have a stored procedure that returns values from a temp table. In my
When I create a temp table using a select into in SQL Server, is
I have a temp table I am creating a query off of in the
I have been reading about the differences between Table Variables and Temp Tables and
I have this code, showmessage('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID); if removedir('C:\TEMP\'+openfiles[openfilelist.ItemIndex].ID) then showmessage('Removed') else showmessage('Failed'); The message shows
If have this in the setter of a property: decimal? temp = value as
I have a file temp.txt, that I want to sort with the sort command
I have a table witch is in intense workload lest say T1 (about 100
If I have a table in Excel, populated via an external data connection, how

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.