Some genius in some of our
CT201AZ OR CT20 1AZ
Don't split the user postcode up - join up the postcode in the db by removing spaces.
You can do this either in a WHERE clause:
SELECT * from Addresses WHERE replace(postcode, ' ', '') = @postcode SELECT * from Addresses2 WHERE areacode + streetcode = @postcode
Or better if possible, create an indexed computed column
ALTER TABLE Addresses ADD PostcodeLookup AS (replace(postcode, ' ', '')) ALTER TABLE Addresses2 ADD PostcodeLookup AS (areacode + streetcode) SELECT * from Addresses WHERE PostcodeLookup = @postcode
You should also remove spaces from the user input.