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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:50:31+00:00 2026-05-28T01:50:31+00:00

What I have is a table with the following columns All columns are nvarchar

  • 0

What I have is a table with the following columns

All columns are nvarchar expect for the Date columns which are datetime

CreateDateA InvIDA StorageIDA CreateDateB InvIDB StorageIDB UniID

What I want to do is move the values on each row (based on UniID) into the represenative B columns where UniID is 1 less, so the ‘A’ columns where UniID = 2 should go to the B Columns where the UniID = 1.

This is the query i’m using but it’s not updating any columns.

update InvSubmission
set CreateDateB = CreateDateA,
InvIDB = InvIDA ,
StorageIDB = StorageIDA 
where StorageIDB = StorageIDA and UniID = (select UniID-1 from InvSubmission)

There is multiple storageid’s in this table, however, each record has a match to at least one other row.

  • 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-28T01:50:32+00:00Added an answer on May 28, 2026 at 1:50 am

    @PinnyM’s answer is close, but in SQL Server, you have to name the updated table in the from clause also:

    update toUpdate
    set CreateDateB = sourceTable.CreateDateA,
        InvIDB = sourceTable.InvIDA
    FROM
        InvSubmission toUpdate
            inner Join
        InvSubmission sourceTable
           ON sourceTable.UniID = toUpdate.UniID + 1
           AND sourceTable.StorageIDA = toUpdate.StorageIDB
    

    Otherwise, this note becomes relevant:

    If the object being updated is the same as the object in the FROM clause and there is only one reference to the object in the FROM clause, an object alias may or may not be specified

    And then you’re suffering the same problem that @Yuck pointed out – you’re trying to compare the UniID value within a single row to a value one less than itself.

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

Sidebar

Related Questions

I have the following table that lists all awarded cups: Name: Cups Columns: Month,
Lets say I have a table with the following columns: Qty, INTEGER SaleDate, DATETIME
I have a table foo which contains the following columns create table foo (
I have a table which contains the following columns: UniqueID remote_ip_addr platform I want
I have a table named CUSTOMERS with the following columns : CUSTOMER_ID (NUMBER), DAY(DATE),
I have a table with the following columns: reportDate DATETIME and losses CURRENCY and
I have a table results, which has he following columns: ID TestCase Platform 1
i have a table genrelink and other genere description in which following columns are
Lets say I have table with following columns 1. Client - string. 2. Profit
I have a table with following columns: ContractorId ......... INT ............. IDENTITY ContractorName ........

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.