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 6200737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:25:24+00:00 2026-05-24T04:25:24+00:00

t1 has an automatically generated primary key called pkId INSERT INTO t1( title, summary)

  • 0

t1 has an automatically generated primary key called pkId

INSERT INTO t1( title, summary)
OUTPUT inserted.pkId, t2.id INTO @IdTable(New_Id, Old_Id)
SELECT t2.title, t2.summary
FROM t2

Can someone please tell me why this doesn’t work?

I’m getting the error The multi-part identifier “t2.id” could not be bound.

  • 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-05-24T04:25:25+00:00Added an answer on May 24, 2026 at 4:25 am

    From Comments

    It doesn’t work because you are not selecting t2.id in your
    SELECT statement. To make it work, you should add t2.id to your
    statement but that would also require you to INSERT this ID in t1 which
    (I assume) is not what you need. I’m still pondering on how to resolve
    that elegantly.

    Not an elegant solution but the easiest might be to

    • Add a dummy t2ID column to t1
    • Alter your INSERT to include the t2ID (not using an OUTPUT clause)
    • Select all new values into your @IdTable
    • Remove the dummy column

    SQL Script

    ALTER TABLE t1 ADD COLUMN t2ID INTEGER NULL
    GO
    
    INSERT INTO t1( title, summary, t2ID)
    SELECT t2.title, t2.summary, t2.ID
    FROM t2
    
    INSERT INTO @IdTable
    SELECT pkID, t2ID
    FROM   t1
    WHERE  t2ID IS NOT NULL
    GO
    
    ALTER TABLE t1 DROP COLUMN t2ID
    GO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project on GitHub that has a directory containing some automatically generated
After running the following SQL statements, you will see that, MySQL has automatically created
Visual Studio has ways to automatically create a method. For example, you could double
Wordpress has a filter that automatically add paragraphs to posts. I can remove this
Visual Studio 2008 has the ability to automatically create unit test stubs. I have
Ruby on Rails has magic timestamping fields that are automatically updated when a record
The bugzilla (perl-based) system has a feature to login automatically by using a http
Microsoft SQL Server has a nice feature, which allows a database to be automatically
I'm trying to make a script that automatically starts uploading after the data has
I have a usercontrol that has several public properties. These properties automatically show up

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.