Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SELECT UK postcodes

Author  Topic 

waxdart23
Starting Member

33 Posts

Posted - 2005-04-02 : 11:30:34
I'm trying to write a select statement to find all the unique first letters in UK postcodes from a table containing all UK postcodes but I am stuck

So for example if my table had:
NE13 6RU
NE7 7BB
LS3 4EB
L23 3BP
SW7 2AP

The select statment I am trying to write would give me:
NE
LS
L
SW

Thanks
Paul

Thanks
P

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-04-02 : 11:51:45
SELECT DISTINCT Left(PostCode, PatIndex('%[^a-z]%', PostCode)-1)
FROM myTable
Go to Top of Page

waxdart23
Starting Member

33 Posts

Posted - 2005-04-02 : 12:45:13
Thanks Robvolk

Thanks
P
Go to Top of Page
   

- Advertisement -