In SQL Server 2012, why do I get the error "The multi-part identifier "T1.Text1" could not be bound." when I run the following statement:
UPDATE DBGUIds SET T1.Text1 = PT.Text1 FROM DBGUIds T1 INNER JOIN
(SELECT InstanceId, EntityId, Text1
FROM
(SELECT InstanceId, EntityId, FieldName, Value FROM TB WHERE TableName = 'DBGUIds') T3
PIVOT
(
MAX(Value) FOR FieldName IN (Text1)
) V) PT ON T1.int1 = PT.InstanceId
Please note that the following statement works ...
SELECT T1.Text1, PT.Text1 FROM DBGUIds T1 INNER JOIN
(SELECT InstanceId, EntityId, Text1
FROM
(SELECT InstanceId, EntityId, FieldName, Value FROM TB WHERE TableName = 'DBGUIds') T3
PIVOT
(
MAX(Value) FOR FieldName IN (Text1)
) V) PT ON T1.int1 = PT.InstanceId
and outputs ...
Text1 Text1
Null 10
Null 20
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.