My tricky SQL Update query not working so well.

Posted by Spooks on Stack Overflow See other posts from Stack Overflow or by Spooks
Published on 2010-06-15T12:35:29Z Indexed on 2010/06/15 13:32 UTC
Read the original article Hit count: 107

Filed under:
|
|

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)

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server