Avatar of al4629740
al4629740Flag for United States of America asked on

insert a column record within the same table between two "identical" records

I have a table named frmRegistrationCSW.

I copied a group of records in the table to make duplicate records.  When I did so I made a mistake and one of the columns did not get copied over.  The column is named 'Sector'  To fix the problem I setup the following code, but I know there are some issues.  I get the error:
Msg 4104, Level 16, State 1, Line 2
The multi-part identifier "R14.Sector" could not be bound.

Help please!

      
UPDATE frmRegistrationCSW
SET R14.Sector = R13.Sector
WHERE ID IN (
SELECT R13.ID
   FROM frmRegistrationCSW AS R13
   INNER JOIN frmRegistrationCSW AS R14
      ON R13.frmRegistrationCSWText2 = R14.frmRegistrationCSWText2
      AND R13.frmRegistrationCSWText4 = R14.frmRegistrationCSWText4
      AND R13.frmRegistrationCSWText5 = R14.frmRegistrationCSWText5
      AND R13.fiscal = 2013
      AND R14.fiscal = 2014
      AND R13.Redetermination = 'Completed'
      AND R13.[CSW/TitleXX] = 'B')

Open in new window

Microsoft SQL Server 2008Microsoft SQL Server

Avatar of undefined
Last Comment
Kyle Abrahams

8/22/2022 - Mon
Kyle Abrahams

UPDATE R14
SET R14.Sector = R13.Sector
from frmRegistrationCSW R14
INNER JOIN frmRegistrationCSW AS R14
                   frmRegistrationCSW AS R13
      ON R13.frmRegistrationCSWText2 = R14.frmRegistrationCSWText2
      AND R13.frmRegistrationCSWText4 = R14.frmRegistrationCSWText4
      AND R13.frmRegistrationCSWText5 = R14.frmRegistrationCSWText5
      AND R13.fiscal = 2013
      AND R14.fiscal = 2014
      AND R13.Redetermination = 'Completed'
      AND R13.[CSW/TitleXX] = 'B'
      AND R13.ID = R14.ID
ASKER
al4629740

Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'frmRegistrationCSW'.
chaau

I do not want to steal point from ged. There is a small typo. He will fix it
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Kyle Abrahams

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question