Hello,
I need to write a query to return the first portion of a postcode, prior to the space, from an existing table. The problem I am having is that the required string can is of variable length - either 2, 3 or 4 characters. For example the postcodes may look as follows:
BU20 7DZ
P16 6GS
E1 2JL
I would want to return the following:
BU20
P16
E1
I have been attempting this using either RTRIM or SUBSTRING - fine for a fixed length string, but how should I adjust to cope with the variable lengths?
Any help would be much appreciated!
Thanks,
-James
I need to write a query to return the first portion of a postcode, prior to the space, from an existing table. The problem I am having is that the required string can is of variable length - either 2, 3 or 4 characters. For example the postcodes may look as follows:
BU20 7DZ
P16 6GS
E1 2JL
I would want to return the following:
BU20
P16
E1
I have been attempting this using either RTRIM or SUBSTRING - fine for a fixed length string, but how should I adjust to cope with the variable lengths?
Any help would be much appreciated!
Thanks,
-James