Bite my bytes

What I learn by day I blog at night.

  Home :: Contact :: Syndication  
  791 Posts :: 3948 Comments :: 235 Trackbacks

Search

Recent Comments.

Recent Posts

Most popular posts
in last 360 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....

Post Feedback

Title:
Name:
Email: (never displayed)
Url:
Comments: 
Please add 6 and 7 and type the answer here: