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
 SQL Server Development (2000)
 Zip from Zip + 4 Script

Author  Topic 

tmtoby
Starting Member

2 Posts

Posted - 2007-08-03 : 14:13:28
Have a list of ZIP + 4 in a sql db. Trying to create a report that rolls up into the parent zip code. For example: two records zip 85040-1234 and 85040-1235 to display together as 85040.

Any suggestions?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-03 : 14:16:46
SELECT Col, LEFT(Col1, CHARINDEX('-', Col1) - 1)
FROM Table1



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

tmtoby
Starting Member

2 Posts

Posted - 2007-08-03 : 14:18:20
Peso is my hero for the day!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-03 : 14:23:58
Or simple SELECT LEFT(Col1, 5) if all column has 5 digits, hyphen and 4 digits.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -