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.
Author |
Topic |
wleonard
Starting Member
30 Posts |
Posted - 2013-09-10 : 16:11:31
|
I'm trying to construct a query that takes results from a table (zip codes, essentially) and strips out the results so that it's just the first 4 digits (rather than the first 4 digits + '-.....'). Which function would allow me to do this in management studio?Will Leonard |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-09-10 : 16:51:12
|
If you just want the first four digits, LEFT(YourExtendedZipCode,4) would do it.But, aren't US zip codes 5 digits? Or, are you thinking about the four-digit portion of the 5+4-digit extended zipcode? |
|
|
wleonard
Starting Member
30 Posts |
Posted - 2013-09-13 : 12:56:32
|
quote: Originally posted by James K If you just want the first four digits, LEFT(YourExtendedZipCode,4) would do it.But, aren't US zip codes 5 digits? Or, are you thinking about the four-digit portion of the 5+4-digit extended zipcode?
Yah yah first 5 was what I meant. Thanks though I'll give this a try.Will Leonard |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-09-15 : 04:07:39
|
it should be either LEFT(Field,5)or if you're sure that there will be a - always separating zip code you can use thisLEFT(field,CHARINDEX('-',field+ '-')-1)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|