Rayzback
asked on
Update Join Query Cannot insert Null
I'm trying to update a particular table with contents from another table but keep getting an error.
UPDATE Cogsdale
SET Cogsdale.ADDRESS1 = Cleaned.Address1, Cogsdale.ADDRESS2 = Cleaned.Address2,
Cogsdale.umCityName = Cleaned.City, Cogsdale.State = Cleaned.State, Cogsdale.umZipCode = Cleaned.Zip
FROM UMRM0112 Cogsdale INNER JOIN RP_CleanAddresses Cleaned
ON Cogsdale.umAddressCode = Cleaned.AddressCode
I get:
Server: Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'STATE', table 'test.dbo.UMRM0112'; column does not allow nulls. UPDATE fails.
The statement has been terminated.
I don't see any nulls in the State field...
UPDATE Cogsdale
SET Cogsdale.ADDRESS1 = Cleaned.Address1, Cogsdale.ADDRESS2 = Cleaned.Address2,
Cogsdale.umCityName = Cleaned.City, Cogsdale.State = Cleaned.State, Cogsdale.umZipCode = Cleaned.Zip
FROM UMRM0112 Cogsdale INNER JOIN RP_CleanAddresses Cleaned
ON Cogsdale.umAddressCode = Cleaned.AddressCode
I get:
Server: Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'STATE', table 'test.dbo.UMRM0112'; column does not allow nulls. UPDATE fails.
The statement has been terminated.
I don't see any nulls in the State field...
Can you recheck the Cleaned table?
try this query
SELECT Cleaned.AddressCode, Cleaned.State
FROM UMRM0112 Cogsdale
INNER JOIN RP_CleanAddresses Cleaned ON Cogsdale.umAddressCode = Cleaned.AddressCode
ORDER BY 2
The nulls should show up at the bottom (or top)
SELECT Cleaned.AddressCode, Cleaned.State
FROM UMRM0112 Cogsdale
INNER JOIN RP_CleanAddresses Cleaned ON Cogsdale.umAddressCode = Cleaned.AddressCode
ORDER BY 2
The nulls should show up at the bottom (or top)
ASKER
Argggg I do... WHERE State = NULL returned nothing?
Can I replace the nulls with ' '?
Can I replace the nulls with ' '?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Change the property of the data element STATE to allow nulls.