Aaron Greene
asked on
UPDATE SQL Statement
I have a table that has been put together from several sources of data. Not all of the data in the original tables was complete. I need to go in and update the missing data. For example, I have the meter serial number in some records and not others. I need to populate the incomplete records with the data from the "good data".
I've created a view of the table to select the rows where METER_SERIAL is populated.
SELECT ACCOUNT_ID, METER_SIZE
FROM dbo.vData_CurrentMonth
WHERE (NOT (METER_SIZE IS NULL))
I want to update tblData with the METER_SIZE data where the ACCOUNT_ID fields are equal.
I've created a view of the table to select the rows where METER_SERIAL is populated.
SELECT ACCOUNT_ID, METER_SIZE
FROM dbo.vData_CurrentMonth
WHERE (NOT (METER_SIZE IS NULL))
I want to update tblData with the METER_SIZE data where the ACCOUNT_ID fields are equal.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi AaronGreene1906,
Try
Try
UPDATE D
SET METER_SIZE=C.METER_SIZE
FROM tblData D INNER JOIN
dbo.vData_CurrentMonth C ON D.ACCOUNT_ID=C.ACCOUNT_ID
WHERE D.METER_SIZE IS NULL AND C.METER_SIZE IS NOT NULL
Try
Open in new window