Start Free Trial
Below code is only updating 1 record. Should be updating the 50 records in the temp table.
SET StateName = StateProvinceDesc
WHERE StateCode = StateProvinceCode
Not sure what the problem is.
Microsoft SQL Server 2008
8/22/2022 - Mon
Are you sure there are 50 records that match? Try writing it this way.
SET s.StateName = sp.StateProvinceDesc
FROM #State s
INNER JOIN StateProvince sp
ON s.StateCode = sp.StateProvinceCode
AL USA AL-USA Alabama
AR USA AR-USA AR-USA
AZ USA AZ-USA AZ-USA
2 AK Alaska USA
1 AL Alabama USA
3 AR Arkansas USA
4 AZ Arizona USA
5 CA California USA
6 CO Colorado USA
7 CT Connecticut USA
You get same results as me, 1 record updated, Alabama.
ASKER CERTIFIED SOLUTION
THIS SOLUTION 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
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I am re-keying the State Province records into the StateProvince table.
I re-keyed 4 records and reran query. Now those records are being updated correctly.
Visually they all look right, so I am not sure why re-keying over the state code in the table is causing the records to now be updateable. ??????????????????????????
I will let you know if this is all fixed after I re-key all records.
Your help has saved me hundreds of hours of internet surfing.
Re-Keyed records and everything is fine now.
Last time I do a copy and paste when creating records in a table.
Plans and Pricing
Certified Expert Program
© 1996-2023 Experts Exchange, LLC. All rights reserved. Covered by US Patent