Account and credit card numbers are stored in a database I hold. To ensure that I am just working with account numbers, I compare these to a file and update any card numbers to the account number.
I built a view connecting the table to the account/card database to return the Table ID and associated account number. Now I need to update the records where the ID and account number match.
The account number field in the Sales Import database needs to be modified.
LeadID |
AccountNumber |
147 |
5807811235 |
150 |
5807811326 |
185 |
7006100100007267039 |
And this is the RetrieveAccountNumber table, where I need to update from:
LeadID |
AccountNumber |
147 |
7006100100007266957 |
150 |
7006100100007267039 |
I tried the below, but no luck so far:
UPDATE [Sales_Lead].[dbo].[Sales_Import]
SET [AccountNumber] = (SELECT RetrieveAccountNumber.AccountNumber
FROM RetrieveAccountNumber
WHERE [Sales_Lead].[dbo].[Sales_Import]. LeadID =
RetrieveAccountNumber.LeadID)
It updates the card numbers to account numbers, but the account numbers get replaced by NULL