I have a table in SQL Server that has a PostalCode column. The data in here is not standardized – Sometimes the postal code appears is H0H 0H0 and othertimes it is H0H0H0. Using SQL only, how can I ensure each of these postal codes is standardized as H0H 0H0 ?
Share
Well, for starters, it really depends on how it’s entered into the database (i.e. you should be controlling how this is entered and managed pre-insertion). But for updating your table, you could do this to put them in the right format, with the space in between:
This might vary depending on the actual database engine. At the time of writing, OP had not specified which.