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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:29:24+00:00 2026-05-15T09:29:24+00:00

I am trying to update a table in my database with another row from

  • 0

I am trying to update a table in my database with another row from another table. I have two parameters one being the ID and another being the row number (as you can select which row you want from the GUI)

this part of the code works fine, this returns one column of a single row.

(SELECT txtPageContent
FROM (select *, Row_Number() OVER (ORDER BY ArchiveDate asc) as rowid 
            from ARC_Content Where ContentID = @ContentID) as test
Where rowid = @rowID)

its just when i try to add the update/set it won’t work. I am probably missing something

UPDATE TBL_Content
Set TBL_Content.txtPageContent = (select txtPageContent
FROM (select *, Row_Number() OVER (ORDER BY ArchiveDate asc) as rowid 
            from ARC_Content Where ContentID = @ContentID) as test
Where rowid = @rowID) 

Thanks for the help! (i have tried top 1 with no avail)

  • 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-15T09:29:24+00:00Added an answer on May 15, 2026 at 9:29 am

    I see a few issues with your update. First, I don’t see any joining or selection criteria for the table that you’re updating. That means that every row in the table will be updated with this new value. Is that really what you want?

    Second, the row number between what is on the GUI and what you get back in the database may not match. Even if you reproduce the query used to create your list in the GUI (which is dangerous anyway, since it involves keeping the update and the select code always in sync), it’s possible that someone could insert or delete or update a row between the time that you fill your list box and send that row number to the server for the update. It’s MUCH better to use PKs (probably IDs in your case) to determine which row to use for updating.

    That said, I think that the following will work for you (untested):

    ;WITH cte AS (
        SELECT
            txtPageContent,
            ROW_NUMBER() OVER (ORDER BY ArchiveDate ASC) AS rowid
        FROM
            ARC_Content
        WHERE
            ContentID = @ContentID)
    UPDATE
        TC
    SET
        txtPageContent = cte.txtPageContent
    FROM
        TBL_Content TC
    INNER JOIN cte ON
        rowid = @rowID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.