So ive found ive got a list of addresses (street, suburb, postcode) and added them into a table tmp_addresses. My idea was to split up the current addresses that are all in one line using the following code:
UPDATE Client
SET ClientCity = t.Suburb
FROM tmp_Addresses t
WHERE ClientAddress LIKE '%' + t.Street + '%' + t.suburb + '%'
UPDATE Client
SET ClientPostcode= t.postcode
FROM tmp_Addresses t
WHERE ClientAddress LIKE '%' + t.Street + '%' + t.suburb + '%'
UPDATE Client
SET ClientAddress2 = ClientAddress
UPDATE Client
SET ClientAddress = LEFT(ClientAddress, 3) + ' ' + t.Street
FROM tmp_Addresses t
WHERE ClientAddress LIKE '%' + t.Street + '%' + t.suburb + '%'
This does work, however it is unbelievably slow, i ran it for around 30 minutes and got 2 results when i searched for suburbs that are not null. Any ideas on how i can speed this up? Initially i tried using:
UPDATE Client
SET ClientCity = t.Suburb
,ClientPostcode = t.Postcode
,ClientAddress = LEFT(ClientAddress, 3) + ' ' + t.Street
FROM tmp_Addresses t
WHERE ClientAddress LIKE '%' + t.Street + '%' + t.suburb + '%'
But i kept getting errors saying ClientPostcode does not exist, not sure why. Either way the above would still take a very long time.
EDIT::
The second section of code now works:
UPDATE Client
SET ClientCity = t.Suburb
,ClientPostcode = t.Postcode
,ClientAddress = LEFT(ClientAddress, 3) + ' ' + t.Street
FROM tmp_Addresses t
WHERE ClientAddress LIKE '%' + t.Street + '%' + t.suburb + '%'
However it is still incredibly slow and is using 98% of the CPU.