Bite my bytes

What I learn by day I blog at night - A blog from Microsoft Consultant working from Ljubljana, Slovenia

  Home :: Contact :: Syndication  
  999 Posts :: 7691 Comments :: 235 Trackbacks

Search

Most popular posts
in last 90 days

Categories

My Projects

Archives

Stuff


Copyright © by David Vidmar
 
Contact me!
 
LinkedIn Profile
 
 
 

Having spent WAY more time building this as appropriate for last hours of Friday, I decided to put this SQL script on the web for everyone.

This are SQL statements for filling countries table. Tables includes numeric, alpha-2 and alpha-3 ISO codes.  Adjust table and column names to your standards and you're good to go. Script is tested on Microsoft SQL Server but it should run / be easily adjustable for any other database.

INSERT INTO Country (CountryID, ISO2, ISO3, Name) VALUES (4, 'AF', 'AFG', 'Afghanistan')
INSERT INTO Country (CountryID, ISO2, ISO3, Name) VALUES (248, 'AX', 'ALA', 'Aland Islands')
INSERT INTO Country (CountryID, ISO2, ISO3, Name) VALUES (8, 'AL', 'ALB', 'Albania')
INSERT INTO Country (CountryID, ISO2, ISO3, Name) VALUES (12, 'DZ', 'DZA', 'Algeria')
INSERT INTO Country (CountryID, ISO2, ISO3, Name) VALUES (16, 'AS', 'ASM', 'American Samoa')
INSERT INTO Country (CountryID, ISO2, ISO3, Name) VALUES (20, 'AD', 'AND', 'Andorra')
INSERT INTO Country (CountryID, ISO2, ISO3, Name) VALUES (24, 'AO', 'AGO', 'Angola')
...

(click for full script)

Compiled from Wikipedia ISO 3166-1 article, last updated on 23rd of May 2008.

 

Here is also "create table" script for for quick start.

create table Country (
   CountryID            int                  not null,
   Iso2                 char(2)              not null,
   Iso3                 char(3)              not null,
   Name                 varchar(100)         not null,
   constraint PK_COUNTRY primary key nonclustered (CountryID)
)

Technorati Tags: ,,,
Posted on Friday, May 23, 2008 5:13 PM | Filed under: Developement |

Feedback

# re: Database of country names, numeric, alpha-2 and alpha-3 ISO codes in SQL 5/24/2008 3:59 PM Felix
I've been doing exactly the same two weeks ago...
Well, not exactly because I was preparing a plain text file with country codes for use in an active directory wrapper.

But anyway, this would've saved me lots of time finding a good list and preparing it so it can be parsed.

So what I wanted to say: Good work!

cheers,
felix

# re: Database of country names, numeric, alpha-2 and alpha-3 ISO codes in SQL 5/24/2008 10:35 PM David
Tnx, Felix.

# re: Database of country names, numeric, alpha-2 and alpha-3 ISO codes in SQL 5/27/2008 11:01 PM Opina
oohhh,, perfect. Just I need.

Comentarios hoteles Spain (opiniones)

# re: Database of country names, numeric, alpha-2 and alpha-3 ISO codes in SQL 7/4/2008 7:36 AM Amit Kumar MIshra
Thanx man, it really golden collection....

# re: Database of country names, numeric, alpha-2 and alpha-3 ISO codes in SQL 1/13/2009 1:30 AM tc
I was just about to do this myself when I thought I'd check if some other poor soul had done this and was kind enough to post their work.

Thank you so much for doing that!


# re: Database of country names, numeric, alpha-2 and alpha-3 ISO codes in SQL 2/16/2009 11:42 AM Keir
Thanks! Just want I was looking for!

# re: Database of country names, numeric, alpha-2 and alpha-3 ISO codes in SQL 3/8/2009 3:00 PM m.j.hashemi
very good i was looking for too
for www.diplomaticlist.net
thanks a lot

# re: Database of country names, numeric, alpha-2 and alpha-3 ISO codes in SQL 3/20/2009 8:30 PM dc
great - thanks - would be nice to add phone dialing codes too

# re: Database of country names, numeric, alpha-2 and alpha-3 ISO codes in SQL 5/24/2009 11:58 AM honzaB
You just saved me a few minutes of time. Perfect, thanks!

# re: Database of country names, numeric, alpha-2 and alpha-3 ISO codes in SQL 11/4/2009 3:39 PM wimpy1
Thanks, this saved me a bunch of time too!

# re: Database of country names, numeric, alpha-2 and alpha-3 ISO codes in SQL 12/18/2009 12:11 PM shivu
ya its really very helpful for me coz in my site i am using .thanks :)

# Thank you so much 10/15/2010 11:31 AM Ashvini
Thank you very much. I was thinking of writing this myself and good luck that I searched on "iso alpha 3 vs alpha 2" .

Comments have been closed on this topic.