Junie01
Right there with Babe
Points: 744
More actions
September 11, 2003 at 8:20 am
#160018
Does anyone have a method of selecting the first xxx chars until a space is encountered?
For example if I have a postcode 'GU14 7NJ', I want to be able to get 'GU14' as the result.
I can't just select the first 4 chars as postcodes are different lengths i.e. W1, CR0
paul_richardson
SSCarpal Tunnel
Points: 4594
September 11, 2003 at 8:24 am
#473732
hi,
try :-
declare @postcode varchar(10), @area_code varchar(10)
select @postcode = 'GU14 7NJ'
select @area_code = substring(@postcode, 1, charindex(" ",@postcode))
print @area_code
HTH
Paul
Edited by - ripg1011 on 09/11/2003 08:25:41 AM
September 11, 2003 at 8:42 am
#473739
perfect - many thanks
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply