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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:58:19+00:00 2026-05-26T20:58:19+00:00

I was asked if you could have an insert statement, which had an ID

  • 0

I was asked if you could have an insert statement, which had an ID field that was an “identity” column, and if the value that was assigned could also be inserted into another field in the same record, in the same insert statement.

Is this possible (SQL Server 2008r2)?

Thanks.

  • 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-26T20:58:20+00:00Added an answer on May 26, 2026 at 8:58 pm

    You cannot really do this – because the actual value that will be used for the IDENTITY column really only is fixed and set when the INSERT has completed.

    You could however use e.g. a trigger

    CREATE TRIGGER trg_YourTableInsertID ON dbo.YourTable 
    AFTER INSERT
    AS 
    UPDATE dbo.YourTable
    SET dbo.YourTable.OtherID = i.ID
    FROM dbo.YourTable t2
    INNER JOIN INSERTED i ON i.ID = t2.ID
    

    This would fire right after any rows have been inserted, and would set the OtherID column to the values of the IDENTITY columns for the inserted rows. But it’s strictly speaking not within the same statement – it’s just after your original statement.

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

Sidebar

Related Questions

There are many functions within the code I am maintaining which have what could
I have been asked to write a grid which tracks flexitime for employees. There
I asked that before, but couldn't figure it out. I have this form: <?php
I asked a similar question yesterday which may have been poorly worded, either way
I have been asked to build a rather simple form processor application that interacts
I am sure this would have been asked before but couldn't find it. Is
I'm new to jquery, and sorry if this question is asked before (could find
This could quite possibly be the dumbest question ever asked. Our client wants us
I was asked this question and could not come up with the answer. Is
This could be a little off the ballpark, but a friend asked me about

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.