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, PMP
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

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
Avatar of al4629740
al4629740
Flag of United States of America image

ASKER

Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'frmRegistrationCSW'.
Avatar of chaau
chaau
Flag of Australia image

I do not want to steal point from ged. There is a small typo. He will fix it
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo