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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:04:34+00:00 2026-05-15T23:04:34+00:00

i have a table with the column id, itemID and locationId. i have now

  • 0

i have a table with the column id, itemID and locationId.

i have now split one locationId into multiple ones so i want to:

Update all records where locationId is 10 and have two rows where locationId is set to 11 and 12 (ItemId would be the same for both rows)

So to start i have:

Id ItemID LocationID
1 1 10

and i want to end up with

Id ItemID LocationID
1 1 11
1 1 12

is there any convenient way of doing this given its an update and an insert at once

  • 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-15T23:04:35+00:00Added an answer on May 15, 2026 at 11:04 pm

    Possibly there’s a single statement that can do it but why wouldn’t you just use transactions, a vendor-agnostic way:

    begin transaction;
    insert into TBL (id,itemid,locationid)
        select id, itemid, 11
        from TBL
        where locationid = 10;
    update TBL
        set locationid = 12
        where locationid = 10;
    commit transaction;
    

    I always tend to use standard SQL where possible so as to be able to switch between vendors easily, never mind the fact I haven’t switched vendors for over a decade now 🙂

    Still, it’s nice to have the ability even if I never use it (though sometimes I’ll go vendor-specific for performance reasons if required – I don’t think that’ll be necessary for this particular use case since it’s probably not something you’ll be doing a lot of).

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

Sidebar

Related Questions

I have a table column where each row has one of three states, and
I try to have this computed column: CREATE TABLE dbo.Item ( ItemId int NOT
I have an ItemList table where there is a groupID column and an itemID
I have a table with a column I would like to update its values.
I have table 1 that represents Items with column ItemID and column ItemInfo. Then,
I have a sql table with a PK column ItemID and unique index on
I have a table of ChildProducts that has a column called ItemID that references
i have this three tables. Table: Item Columns: ItemID, Title, Content, NoChange (Date) Table:
I have table with column Percentage varchar(10) Data in that table is Pecentage 2/10
I have a table column I’m trying to expand and hide. jQuery seems to

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.