tags:

views:

467

answers:

8

Where can I find a list of the US States in a form for importing into my database?

SQL would be ideal, otherwise CSV or some other flat file format is fine.

Edit: Complete with the two letter state codes

+10  A: 

I needed this a few weeks ago and put it on my blog as SQL and Tab Delimited. The data was sourced from wikipedia in early January so should be up to date.

US States: http://www.john.geek.nz/index.php/2009/01/sql-tips-list-of-us-states/

I use the Worlds Simplest Code Generator if I need to add columns or remove some of the fields - http://secretgeek.net/wscg.asp

I've also done Countries of the world and International Dialling Codes too.
Countries: http://www.john.geek.nz/index.php/2009/01/sql-tips-list-of-countries/
IDC's: http://www.john.geek.nz/index.php/2009/01/sql-tips-list-of-international-dialling-codes-idcs/

Edit: New: Towns and cities of New Zealand

John
Thanks. I might just use the International Dialling Codes too.
You're missing Washington, DC. True, not technically a state, but I can't imagine many real world applications that would intentionally wish to exclude it.
Eli
Thanks, I've added District of Columbia to the list
John
+6  A: 

Out of interest: As there are only 50 and they rarely change, couldn't you not just manually create such a list from a source and put it on a public webspace?

Michael Stum
+1 cause I laughed at the "... and they rarely change"
Unkwntech
No US President has yet been born and died with the same number of stars on the flag. So on past form, they change at least once per Presidential lifetime, and we can expect Puerto Rico to be a state before Obama dies (he's the first President born post-Hawaii) :-)
Steve Jessop
+9  A: 

Cut/Paste these into notepad and then import..should be easy enough - there are only 50 after all:

 Alabama
 Alaska
 Arizona
 Arkansas
 California
 Colorado
 Connecticut
 Delaware
 Florida
 Georgia
 Hawaii
 Idaho
 Illinois
 Indiana
 Iowa
 Kansas
 Kentucky
 Louisiana
 Maine
 Maryland
 Massachusetts
 Michigan
 Minnesota
 Mississippi
 Missouri
 Montana
 Nebraska
 Nevada
 New Hampshire
 New Jersey
 New Mexico
 New York
 North Carolina
 North Dakota
 Ohio
 Oklahoma
 Oregon
 Pennsylvania
 Rhode Island
 South Carolina
 South Dakota
 Tennessee
 Texas
 Utah
 Vermont
 Virginia
 Washington
 West Virginia
 Wisconsin
 Wyoming
EJB
Noooo, it can't be *that* simple. :-D +1 (But then again - maybe the US are planning on extending that list anytime soon, or evict unprofitable states?)
Tomalak
I nominate Alaska! :-P
Bill Karwin
Huh? Canada is missing from the list? (couldn't resist)
Leon Bambrick
You're missing Washington, DC. True, it's technically not a state, but you probably want it in the list just the same.
Eli
+1  A: 

If you need to memorize them, let Wakko help you :)

Paul Dixon
+1  A: 

You can download a lot of lists on http://www.freebase.com/ .

tuinstoel
+13  A: 

Depending on why you need the states, it is worth keeping in mind that there are more than 50 valid state codes. For someone deployed outside the USA, it is annoying to come across websites that do not allow address entry with perfectly valid state codes like AE and AP. A better resource would be USPS (http://www.usps.com/ncsc/lookups/usps_abbreviations.html).

cheers, jason

cspoe7
A: 

http://www.geonames.org/export/

The GeoNames geographical database is available for download free of charge under a creative commons attribution license. It contains over eight million geographical names and consists of 6.5 million unique features whereof 2.2 million populated places and 1.8 million alternate names. All features are categorized into one out of nine feature classes and further subcategorized into one out of 645 feature codes. (more statistics ...). The data is accessible free of charge through a number of webservices and a daily database export.

A: 

You could use google sets to make a list of all states as well as lists of more or less anything.

Rune Grimstad