I Need Countries List in T-SQL

前端 未结 5 1583
不知归路
不知归路 2021-02-13 04:28

I have a Country table which has CountryName column. I need a ready made list in DDL to populate in the column CountryName.

The table resides in SQL Server 2008.

相关标签:
5条回答
  • 2021-02-13 05:03
    CREATE TABLE `apps_countries` (
    `id` int(11) NOT NULL auto_increment,
    `country_code` varchar(2) NOT NULL default '',
    `country_name` varchar(100) NOT NULL default '',
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    -- 
    -- Dumping data for table `apps_countries`
    -- 
    INSERT INTO `apps_countries` VALUES (null, 'AF', 'Afghanistan');
    INSERT INTO `apps_countries` VALUES (null, 'AL', 'Albania');
    INSERT INTO `apps_countries` VALUES (null, 'DZ', 'Algeria');
    INSERT INTO `apps_countries` VALUES (null, 'DS', 'American Samoa');
    INSERT INTO `apps_countries` VALUES (null, 'AD', 'Andorra');
    INSERT INTO `apps_countries` VALUES (null, 'AO', 'Angola');
    INSERT INTO `apps_countries` VALUES (null, 'AI', 'Anguilla');
    INSERT INTO `apps_countries` VALUES (null, 'AQ', 'Antarctica');
    INSERT INTO `apps_countries` VALUES (null, 'AG', 'Antigua and Barbuda');
    INSERT INTO `apps_countries` VALUES (null, 'AR', 'Argentina');
    INSERT INTO `apps_countries` VALUES (null, 'AM', 'Armenia');
    INSERT INTO `apps_countries` VALUES (null, 'AW', 'Aruba');
    INSERT INTO `apps_countries` VALUES (null, 'AU', 'Australia');
    INSERT INTO `apps_countries` VALUES (null, 'AT', 'Austria');
    INSERT INTO `apps_countries` VALUES (null, 'AZ', 'Azerbaijan');
    INSERT INTO `apps_countries` VALUES (null, 'BS', 'Bahamas');
    INSERT INTO `apps_countries` VALUES (null, 'BH', 'Bahrain');
    INSERT INTO `apps_countries` VALUES (null, 'BD', 'Bangladesh');
    INSERT INTO `apps_countries` VALUES (null, 'BB', 'Barbados');
    INSERT INTO `apps_countries` VALUES (null, 'BY', 'Belarus');
    INSERT INTO `apps_countries` VALUES (null, 'BE', 'Belgium');
    INSERT INTO `apps_countries` VALUES (null, 'BZ', 'Belize');
    INSERT INTO `apps_countries` VALUES (null, 'BJ', 'Benin');
    INSERT INTO `apps_countries` VALUES (null, 'BM', 'Bermuda');
    INSERT INTO `apps_countries` VALUES (null, 'BT', 'Bhutan');
    INSERT INTO `apps_countries` VALUES (null, 'BO', 'Bolivia');
    INSERT INTO `apps_countries` VALUES (null, 'BA', 'Bosnia and Herzegovina');
    INSERT INTO `apps_countries` VALUES (null, 'BW', 'Botswana');
    INSERT INTO `apps_countries` VALUES (null, 'BV', 'Bouvet Island');
    INSERT INTO `apps_countries` VALUES (null, 'BR', 'Brazil');
    INSERT INTO `apps_countries` VALUES (null, 'IO', 'British Indian Ocean Territory');
    INSERT INTO `apps_countries` VALUES (null, 'BN', 'Brunei Darussalam');
    INSERT INTO `apps_countries` VALUES (null, 'BG', 'Bulgaria');
    INSERT INTO `apps_countries` VALUES (null, 'BF', 'Burkina Faso');
    INSERT INTO `apps_countries` VALUES (null, 'BI', 'Burundi');
    INSERT INTO `apps_countries` VALUES (null, 'KH', 'Cambodia');
    INSERT INTO `apps_countries` VALUES (null, 'CM', 'Cameroon');
    INSERT INTO `apps_countries` VALUES (null, 'CA', 'Canada');
    INSERT INTO `apps_countries` VALUES (null, 'CV', 'Cape Verde');
    INSERT INTO `apps_countries` VALUES (null, 'KY', 'Cayman Islands');
    INSERT INTO `apps_countries` VALUES (null, 'CF', 'Central African Republic');
    INSERT INTO `apps_countries` VALUES (null, 'TD', 'Chad');
    INSERT INTO `apps_countries` VALUES (null, 'CL', 'Chile');
    INSERT INTO `apps_countries` VALUES (null, 'CN', 'China');
    INSERT INTO `apps_countries` VALUES (null, 'CX', 'Christmas Island');
    INSERT INTO `apps_countries` VALUES (null, 'CC', 'Cocos (Keeling) Islands');
    INSERT INTO `apps_countries` VALUES (null, 'CO', 'Colombia');
    INSERT INTO `apps_countries` VALUES (null, 'KM', 'Comoros');
    INSERT INTO `apps_countries` VALUES (null, 'CD', 'Democratic Republic of the Congo');
    INSERT INTO `apps_countries` VALUES (null, 'CG', 'Republic of Congo');
    INSERT INTO `apps_countries` VALUES (null, 'CK', 'Cook Islands');
    INSERT INTO `apps_countries` VALUES (null, 'CR', 'Costa Rica');
    INSERT INTO `apps_countries` VALUES (null, 'HR', 'Croatia (Hrvatska)');
    INSERT INTO `apps_countries` VALUES (null, 'CU', 'Cuba');
    INSERT INTO `apps_countries` VALUES (null, 'CY', 'Cyprus');
    INSERT INTO `apps_countries` VALUES (null, 'CZ', 'Czech Republic');
    INSERT INTO `apps_countries` VALUES (null, 'DK', 'Denmark');
    INSERT INTO `apps_countries` VALUES (null, 'DJ', 'Djibouti');
    INSERT INTO `apps_countries` VALUES (null, 'DM', 'Dominica');
    INSERT INTO `apps_countries` VALUES (null, 'DO', 'Dominican Republic');
    INSERT INTO `apps_countries` VALUES (null, 'TP', 'East Timor');
    INSERT INTO `apps_countries` VALUES (null, 'EC', 'Ecuador');
    INSERT INTO `apps_countries` VALUES (null, 'EG', 'Egypt');
    INSERT INTO `apps_countries` VALUES (null, 'SV', 'El Salvador');
    INSERT INTO `apps_countries` VALUES (null, 'GQ', 'Equatorial Guinea');
    INSERT INTO `apps_countries` VALUES (null, 'ER', 'Eritrea');
    INSERT INTO `apps_countries` VALUES (null, 'EE', 'Estonia');
    INSERT INTO `apps_countries` VALUES (null, 'ET', 'Ethiopia');
    INSERT INTO `apps_countries` VALUES (null, 'FK', 'Falkland Islands (Malvinas)');
    INSERT INTO `apps_countries` VALUES (null, 'FO', 'Faroe Islands');
    INSERT INTO `apps_countries` VALUES (null, 'FJ', 'Fiji');
    INSERT INTO `apps_countries` VALUES (null, 'FI', 'Finland');
    INSERT INTO `apps_countries` VALUES (null, 'FR', 'France');
    INSERT INTO `apps_countries` VALUES (null, 'FX', 'France, Metropolitan');
    INSERT INTO `apps_countries` VALUES (null, 'GF', 'French Guiana');
    INSERT INTO `apps_countries` VALUES (null, 'PF', 'French Polynesia');
    INSERT INTO `apps_countries` VALUES (null, 'TF', 'French Southern Territories');
    INSERT INTO `apps_countries` VALUES (null, 'GA', 'Gabon');
    INSERT INTO `apps_countries` VALUES (null, 'GM', 'Gambia');
    INSERT INTO `apps_countries` VALUES (null, 'GE', 'Georgia');
    INSERT INTO `apps_countries` VALUES (null, 'DE', 'Germany');
    INSERT INTO `apps_countries` VALUES (null, 'GH', 'Ghana');
    INSERT INTO `apps_countries` VALUES (null, 'GI', 'Gibraltar');
    INSERT INTO `apps_countries` VALUES (null, 'GK', 'Guernsey');
    INSERT INTO `apps_countries` VALUES (null, 'GR', 'Greece');
    INSERT INTO `apps_countries` VALUES (null, 'GL', 'Greenland');
    INSERT INTO `apps_countries` VALUES (null, 'GD', 'Grenada');
    INSERT INTO `apps_countries` VALUES (null, 'GP', 'Guadeloupe');
    INSERT INTO `apps_countries` VALUES (null, 'GU', 'Guam');
    INSERT INTO `apps_countries` VALUES (null, 'GT', 'Guatemala');
    INSERT INTO `apps_countries` VALUES (null, 'GN', 'Guinea');
    INSERT INTO `apps_countries` VALUES (null, 'GW', 'Guinea-Bissau');
    INSERT INTO `apps_countries` VALUES (null, 'GY', 'Guyana');
    INSERT INTO `apps_countries` VALUES (null, 'HT', 'Haiti');
    INSERT INTO `apps_countries` VALUES (null, 'HM', 'Heard and Mc Donald Islands');
    INSERT INTO `apps_countries` VALUES (null, 'HN', 'Honduras');
    INSERT INTO `apps_countries` VALUES (null, 'HK', 'Hong Kong');
    INSERT INTO `apps_countries` VALUES (null, 'HU', 'Hungary');
    INSERT INTO `apps_countries` VALUES (null, 'IS', 'Iceland');
    INSERT INTO `apps_countries` VALUES (null, 'IN', 'India');
    INSERT INTO `apps_countries` VALUES (null, 'IM', 'Isle of Man');
    INSERT INTO `apps_countries` VALUES (null, 'ID', 'Indonesia');
    INSERT INTO `apps_countries` VALUES (null, 'IR', 'Iran (Islamic Republic of)');
    INSERT INTO `apps_countries` VALUES (null, 'IQ', 'Iraq');
    INSERT INTO `apps_countries` VALUES (null, 'IE', 'Ireland');
    INSERT INTO `apps_countries` VALUES (null, 'IL', 'Israel');
    INSERT INTO `apps_countries` VALUES (null, 'IT', 'Italy');
    INSERT INTO `apps_countries` VALUES (null, 'CI', 'Ivory Coast');
    INSERT INTO `apps_countries` VALUES (null, 'JE', 'Jersey');
    INSERT INTO `apps_countries` VALUES (null, 'JM', 'Jamaica');
    INSERT INTO `apps_countries` VALUES (null, 'JP', 'Japan');
    INSERT INTO `apps_countries` VALUES (null, 'JO', 'Jordan');
    INSERT INTO `apps_countries` VALUES (null, 'KZ', 'Kazakhstan');
    INSERT INTO `apps_countries` VALUES (null, 'KE', 'Kenya');
    INSERT INTO `apps_countries` VALUES (null, 'KI', 'Kiribati');
    INSERT INTO `apps_countries` VALUES (null, 'KP', 'Korea, Democratic People''s Republic of');
    INSERT INTO `apps_countries` VALUES (null, 'KR', 'Korea, Republic of');
    INSERT INTO `apps_countries` VALUES (null, 'XK', 'Kosovo');
    INSERT INTO `apps_countries` VALUES (null, 'KW', 'Kuwait');
    INSERT INTO `apps_countries` VALUES (null, 'KG', 'Kyrgyzstan');
    INSERT INTO `apps_countries` VALUES (null, 'LA', 'Lao People''s Democratic Republic');
    INSERT INTO `apps_countries` VALUES (null, 'LV', 'Latvia');
    INSERT INTO `apps_countries` VALUES (null, 'LB', 'Lebanon');
    INSERT INTO `apps_countries` VALUES (null, 'LS', 'Lesotho');
    INSERT INTO `apps_countries` VALUES (null, 'LR', 'Liberia');
    INSERT INTO `apps_countries` VALUES (null, 'LY', 'Libyan Arab Jamahiriya');
    INSERT INTO `apps_countries` VALUES (null, 'LI', 'Liechtenstein');
    INSERT INTO `apps_countries` VALUES (null, 'LT', 'Lithuania');
    INSERT INTO `apps_countries` VALUES (null, 'LU', 'Luxembourg');
    INSERT INTO `apps_countries` VALUES (null, 'MO', 'Macau');
    INSERT INTO `apps_countries` VALUES (null, 'MK', 'North Macedonia');
    INSERT INTO `apps_countries` VALUES (null, 'MG', 'Madagascar');
    INSERT INTO `apps_countries` VALUES (null, 'MW', 'Malawi');
    INSERT INTO `apps_countries` VALUES (null, 'MY', 'Malaysia');
    INSERT INTO `apps_countries` VALUES (null, 'MV', 'Maldives');
    INSERT INTO `apps_countries` VALUES (null, 'ML', 'Mali');
    INSERT INTO `apps_countries` VALUES (null, 'MT', 'Malta');
    INSERT INTO `apps_countries` VALUES (null, 'MH', 'Marshall Islands');
    INSERT INTO `apps_countries` VALUES (null, 'MQ', 'Martinique');
    INSERT INTO `apps_countries` VALUES (null, 'MR', 'Mauritania');
    INSERT INTO `apps_countries` VALUES (null, 'MU', 'Mauritius');
    INSERT INTO `apps_countries` VALUES (null, 'TY', 'Mayotte');
    INSERT INTO `apps_countries` VALUES (null, 'MX', 'Mexico');
    INSERT INTO `apps_countries` VALUES (null, 'FM', 'Micronesia, Federated States of');
    INSERT INTO `apps_countries` VALUES (null, 'MD', 'Moldova, Republic of');
    INSERT INTO `apps_countries` VALUES (null, 'MC', 'Monaco');
    INSERT INTO `apps_countries` VALUES (null, 'MN', 'Mongolia');
    INSERT INTO `apps_countries` VALUES (null, 'ME', 'Montenegro');
    INSERT INTO `apps_countries` VALUES (null, 'MS', 'Montserrat');
    INSERT INTO `apps_countries` VALUES (null, 'MA', 'Morocco');
    INSERT INTO `apps_countries` VALUES (null, 'MZ', 'Mozambique');
    INSERT INTO `apps_countries` VALUES (null, 'MM', 'Myanmar');
    INSERT INTO `apps_countries` VALUES (null, 'NA', 'Namibia');
    INSERT INTO `apps_countries` VALUES (null, 'NR', 'Nauru');
    INSERT INTO `apps_countries` VALUES (null, 'NP', 'Nepal');
    INSERT INTO `apps_countries` VALUES (null, 'NL', 'Netherlands');
    INSERT INTO `apps_countries` VALUES (null, 'AN', 'Netherlands Antilles');
    INSERT INTO `apps_countries` VALUES (null, 'NC', 'New Caledonia');
    INSERT INTO `apps_countries` VALUES (null, 'NZ', 'New Zealand');
    INSERT INTO `apps_countries` VALUES (null, 'NI', 'Nicaragua');
    INSERT INTO `apps_countries` VALUES (null, 'NE', 'Niger');
    INSERT INTO `apps_countries` VALUES (null, 'NG', 'Nigeria');
    INSERT INTO `apps_countries` VALUES (null, 'NU', 'Niue');
    INSERT INTO `apps_countries` VALUES (null, 'NF', 'Norfolk Island');
    INSERT INTO `apps_countries` VALUES (null, 'MP', 'Northern Mariana Islands');
    INSERT INTO `apps_countries` VALUES (null, 'NO', 'Norway');
    INSERT INTO `apps_countries` VALUES (null, 'OM', 'Oman');
    INSERT INTO `apps_countries` VALUES (null, 'PK', 'Pakistan');
    INSERT INTO `apps_countries` VALUES (null, 'PW', 'Palau');
    INSERT INTO `apps_countries` VALUES (null, 'PS', 'Palestine');
    INSERT INTO `apps_countries` VALUES (null, 'PA', 'Panama');
    INSERT INTO `apps_countries` VALUES (null, 'PG', 'Papua New Guinea');
    INSERT INTO `apps_countries` VALUES (null, 'PY', 'Paraguay');
    INSERT INTO `apps_countries` VALUES (null, 'PE', 'Peru');
    INSERT INTO `apps_countries` VALUES (null, 'PH', 'Philippines');
    INSERT INTO `apps_countries` VALUES (null, 'PN', 'Pitcairn');
    INSERT INTO `apps_countries` VALUES (null, 'PL', 'Poland');
    INSERT INTO `apps_countries` VALUES (null, 'PT', 'Portugal');
    INSERT INTO `apps_countries` VALUES (null, 'PR', 'Puerto Rico');
    INSERT INTO `apps_countries` VALUES (null, 'QA', 'Qatar');
    INSERT INTO `apps_countries` VALUES (null, 'RE', 'Reunion');
    INSERT INTO `apps_countries` VALUES (null, 'RO', 'Romania');
    INSERT INTO `apps_countries` VALUES (null, 'RU', 'Russian Federation');
    INSERT INTO `apps_countries` VALUES (null, 'RW', 'Rwanda');
    INSERT INTO `apps_countries` VALUES (null, 'KN', 'Saint Kitts and Nevis');
    INSERT INTO `apps_countries` VALUES (null, 'LC', 'Saint Lucia');
    INSERT INTO `apps_countries` VALUES (null, 'VC', 'Saint Vincent and the Grenadines');
    INSERT INTO `apps_countries` VALUES (null, 'WS', 'Samoa');
    INSERT INTO `apps_countries` VALUES (null, 'SM', 'San Marino');
    INSERT INTO `apps_countries` VALUES (null, 'ST', 'Sao Tome and Principe');
    INSERT INTO `apps_countries` VALUES (null, 'SA', 'Saudi Arabia');
    INSERT INTO `apps_countries` VALUES (null, 'SN', 'Senegal');
    INSERT INTO `apps_countries` VALUES (null, 'RS', 'Serbia');
    INSERT INTO `apps_countries` VALUES (null, 'SC', 'Seychelles');
    INSERT INTO `apps_countries` VALUES (null, 'SL', 'Sierra Leone');
    INSERT INTO `apps_countries` VALUES (null, 'SG', 'Singapore');
    INSERT INTO `apps_countries` VALUES (null, 'SK', 'Slovakia');
    INSERT INTO `apps_countries` VALUES (null, 'SI', 'Slovenia');
    INSERT INTO `apps_countries` VALUES (null, 'SB', 'Solomon Islands');
    INSERT INTO `apps_countries` VALUES (null, 'SO', 'Somalia');
    INSERT INTO `apps_countries` VALUES (null, 'ZA', 'South Africa');
    INSERT INTO `apps_countries` VALUES (null, 'GS', 'South Georgia South Sandwich Islands');
    INSERT INTO `apps_countries` VALUES (null, 'SS', 'South Sudan');
    INSERT INTO `apps_countries` VALUES (null, 'ES', 'Spain');
    INSERT INTO `apps_countries` VALUES (null, 'LK', 'Sri Lanka');
    INSERT INTO `apps_countries` VALUES (null, 'SH', 'St. Helena');
    INSERT INTO `apps_countries` VALUES (null, 'PM', 'St. Pierre and Miquelon');
    INSERT INTO `apps_countries` VALUES (null, 'SD', 'Sudan');
    INSERT INTO `apps_countries` VALUES (null, 'SR', 'Suriname');
    INSERT INTO `apps_countries` VALUES (null, 'SJ', 'Svalbard and Jan Mayen Islands');
    INSERT INTO `apps_countries` VALUES (null, 'SZ', 'Swaziland');
    INSERT INTO `apps_countries` VALUES (null, 'SE', 'Sweden');
    INSERT INTO `apps_countries` VALUES (null, 'CH', 'Switzerland');
    INSERT INTO `apps_countries` VALUES (null, 'SY', 'Syrian Arab Republic');
    INSERT INTO `apps_countries` VALUES (null, 'TW', 'Taiwan');
    INSERT INTO `apps_countries` VALUES (null, 'TJ', 'Tajikistan');
    INSERT INTO `apps_countries` VALUES (null, 'TZ', 'Tanzania, United Republic of');
    INSERT INTO `apps_countries` VALUES (null, 'TH', 'Thailand');
    INSERT INTO `apps_countries` VALUES (null, 'TG', 'Togo');
    INSERT INTO `apps_countries` VALUES (null, 'TK', 'Tokelau');
    INSERT INTO `apps_countries` VALUES (null, 'TO', 'Tonga');
    INSERT INTO `apps_countries` VALUES (null, 'TT', 'Trinidad and Tobago');
    INSERT INTO `apps_countries` VALUES (null, 'TN', 'Tunisia');
    INSERT INTO `apps_countries` VALUES (null, 'TR', 'Turkey');
    INSERT INTO `apps_countries` VALUES (null, 'TM', 'Turkmenistan');
    INSERT INTO `apps_countries` VALUES (null, 'TC', 'Turks and Caicos Islands');
    INSERT INTO `apps_countries` VALUES (null, 'TV', 'Tuvalu');
    INSERT INTO `apps_countries` VALUES (null, 'UG', 'Uganda');
    INSERT INTO `apps_countries` VALUES (null, 'UA', 'Ukraine');
    INSERT INTO `apps_countries` VALUES (null, 'AE', 'United Arab Emirates');
    INSERT INTO `apps_countries` VALUES (null, 'GB', 'United Kingdom');
    INSERT INTO `apps_countries` VALUES (null, 'US', 'United States');
    INSERT INTO `apps_countries` VALUES (null, 'UM', 'United States minor outlying islands');
    INSERT INTO `apps_countries` VALUES (null, 'UY', 'Uruguay');
    INSERT INTO `apps_countries` VALUES (null, 'UZ', 'Uzbekistan');
    INSERT INTO `apps_countries` VALUES (null, 'VU', 'Vanuatu');
    INSERT INTO `apps_countries` VALUES (null, 'VA', 'Vatican City State');
    INSERT INTO `apps_countries` VALUES (null, 'VE', 'Venezuela');
    INSERT INTO `apps_countries` VALUES (null, 'VN', 'Vietnam');
    INSERT INTO `apps_countries` VALUES (null, 'VG', 'Virgin Islands (British)');
    INSERT INTO `apps_countries` VALUES (null, 'VI', 'Virgin Islands (U.S.)');
    INSERT INTO `apps_countries` VALUES (null, 'WF', 'Wallis and Futuna Islands');
    INSERT INTO `apps_countries` VALUES (null, 'EH', 'Western Sahara');
    INSERT INTO `apps_countries` VALUES (null, 'YE', 'Yemen');
    INSERT INTO `apps_countries` VALUES (null, 'ZM', 'Zambia');
    INSERT INTO `apps_countries` VALUES (null, 'ZW', 'Zimbabwe');
    
    0 讨论(0)
  • 2021-02-13 05:08

    You can try this script:

    CREATE TABLE tbl_Countries
    (
         CountryID INT
        ,CountryName VARCHAR(50)
        ,TwoCharCountryCode CHAR(2)
        ,ThreeCharCountryCode CHAR(3)    
    );
    
    
    INSERT INTO tbl_Countries VALUES 
    (1,'Afghanistan','AF','AFG')
    ,(2,'Aland Islands','AX','ALA')
    ,(3,'Albania','AL','ALB')
    ,(4,'Algeria','DZ','DZA')
    ,(5,'American Samoa','AS','ASM')
    ,(6,'Andorra','AD','AND')
    ,(7,'Angola','AO','AGO')
    ,(8,'Anguilla','AI','AIA')
    ,(9,'Antarctica','AQ','ATA')
    ,(10,'Antigua and Barbuda','AG','ATG')
    ,(11,'Argentina','AR','ARG')
    ,(12,'Armenia','AM','ARM')
    ,(13,'Aruba','AW','ABW')
    ,(14,'Australia','AU','AUS')
    ,(15,'Austria','AT','AUT')
    ,(16,'Azerbaijan','AZ','AZE')
    ,(17,'Bahamas','BS','BHS')
    ,(18,'Bahrain','BH','BHR')
    ,(19,'Bangladesh','BD','BGD')
    ,(20,'Barbados','BB','BRB')
    ,(21,'Belarus','BY','BLR')
    ,(22,'Belgium','BE','BEL')
    ,(23,'Belize','BZ','BLZ')
    ,(24,'Benin','BJ','BEN')
    ,(25,'Bermuda','BM','BMU')
    ,(26,'Bhutan','BT','BTN')
    ,(27,'Bolivia','BO','BOL')
    ,(28,'Bonaire, Sint Eustatius and Saba','BQ','BES')
    ,(29,'Bosnia and Herzegovina','BA','BIH')
    ,(30,'Botswana','BW','BWA')
    ,(31,'Bouvet Island','BV','BVT')
    ,(32,'Brazil','BR','BRA')
    ,(33,'British Indian Ocean Territory','IO','IOT')
    ,(34,'Brunei','BN','BRN')
    ,(35,'Bulgaria','BG','BGR')
    ,(36,'Burkina Faso','BF','BFA')
    ,(37,'Burundi','BI','BDI')
    ,(38,'Cambodia','KH','KHM')
    ,(39,'Cameroon','CM','CMR')
    ,(40,'Canada','CA','CAN')
    ,(41,'Cape Verde','CV','CPV')
    ,(42,'Cayman Islands','KY','CYM')
    ,(43,'Central African Republic','CF','CAF')
    ,(44,'Chad','TD','TCD')
    ,(45,'Chile','CL','CHL')
    ,(46,'China','CN','CHN')
    ,(47,'Christmas Island','CX','CXR')
    ,(48,'Cocos (Keeling) Islands','CC','CCK')
    ,(49,'Colombia','CO','COL')
    ,(50,'Comoros','KM','COM')
    ,(51,'Congo','CG','COG')
    ,(52,'Cook Islands','CK','COK')
    ,(53,'Costa Rica','CR','CRI')
    ,(54,'Ivory Coast','CI','CIV')
    ,(55,'Croatia','HR','HRV')
    ,(56,'Cuba','CU','CUB')
    ,(57,'Curacao','CW','CUW')
    ,(58,'Cyprus','CY','CYP')
    ,(59,'Czech Republic','CZ','CZE')
    ,(60,'Democratic Republic of the Congo','CD','COD')
    ,(61,'Denmark','DK','DNK')
    ,(62,'Djibouti','DJ','DJI')
    ,(63,'Dominica','DM','DMA')
    ,(64,'Dominican Republic','DO','DOM')
    ,(65,'Ecuador','EC','ECU')
    ,(66,'Egypt','EG','EGY')
    ,(67,'El Salvador','SV','SLV')
    ,(68,'Equatorial Guinea','GQ','GNQ')
    ,(69,'Eritrea','ER','ERI')
    ,(70,'Estonia','EE','EST')
    ,(71,'Ethiopia','ET','ETH')
    ,(72,'Falkland Islands (Malvinas)','FK','FLK')
    ,(73,'Faroe Islands','FO','FRO')
    ,(74,'Fiji','FJ','FJI')
    ,(75,'Finland','FI','FIN')
    ,(76,'France','FR','FRA')
    ,(77,'French Guiana','GF','GUF')
    ,(78,'French Polynesia','PF','PYF')
    ,(79,'French Southern Territories','TF','ATF')
    ,(80,'Gabon','GA','GAB')
    ,(81,'Gambia','GM','GMB')
    ,(82,'Georgia','GE','GEO')
    ,(83,'Germany','DE','DEU')
    ,(84,'Ghana','GH','GHA')
    ,(85,'Gibraltar','GI','GIB')
    ,(86,'Greece','GR','GRC')
    ,(87,'Greenland','GL','GRL')
    ,(88,'Grenada','GD','GRD')
    ,(89,'Guadaloupe','GP','GLP')
    ,(90,'Guam','GU','GUM')
    ,(91,'Guatemala','GT','GTM')
    ,(92,'Guernsey','GG','GGY')
    ,(93,'Guinea','GN','GIN')
    ,(94,'Guinea-Bissau','GW','GNB')
    ,(95,'Guyana','GY','GUY')
    ,(96,'Haiti','HT','HTI')
    ,(97,'Heard Island and McDonald Islands','HM','HMD')
    ,(98,'Honduras','HN','HND')
    ,(99,'Hong Kong','HK','HKG')
    ,(100,'Hungary','HU','HUN')
    ,(101,'Iceland','IS','ISL')
    ,(102,'India','IN','IND')
    ,(103,'Indonesia','ID','IDN')
    ,(104,'Iran','IR','IRN')
    ,(105,'Iraq','IQ','IRQ')
    ,(106,'Ireland','IE','IRL')
    ,(107,'Isle of Man','IM','IMN')
    ,(108,'Israel','IL','ISR')
    ,(109,'Italy','IT','ITA')
    ,(110,'Jamaica','JM','JAM')
    ,(111,'Japan','JP','JPN')
    ,(112,'Jersey','JE','JEY')
    ,(113,'Jordan','JO','JOR')
    ,(114,'Kazakhstan','KZ','KAZ')
    ,(115,'Kenya','KE','KEN')
    ,(116,'Kiribati','KI','KIR')
    ,(117,'Kosovo','XK','---')
    ,(118,'Kuwait','KW','KWT')
    ,(119,'Kyrgyzstan','KG','KGZ')
    ,(120,'Laos','LA','LAO')
    ,(121,'Latvia','LV','LVA')
    ,(122,'Lebanon','LB','LBN')
    ,(123,'Lesotho','LS','LSO')
    ,(124,'Liberia','LR','LBR')
    ,(125,'Libya','LY','LBY')
    ,(126,'Liechtenstein','LI','LIE')
    ,(127,'Lithuania','LT','LTU')
    ,(128,'Luxembourg','LU','LUX')
    ,(129,'Macao','MO','MAC')
    ,(130,'Macedonia','MK','MKD')
    ,(131,'Madagascar','MG','MDG')
    ,(132,'Malawi','MW','MWI')
    ,(133,'Malaysia','MY','MYS')
    ,(134,'Maldives','MV','MDV')
    ,(135,'Mali','ML','MLI')
    ,(136,'Malta','MT','MLT')
    ,(137,'Marshall Islands','MH','MHL')
    ,(138,'Martinique','MQ','MTQ')
    ,(139,'Mauritania','MR','MRT')
    ,(140,'Mauritius','MU','MUS')
    ,(141,'Mayotte','YT','MYT')
    ,(142,'Mexico','MX','MEX')
    ,(143,'Micronesia','FM','FSM')
    ,(144,'Moldava','MD','MDA')
    ,(145,'Monaco','MC','MCO')
    ,(146,'Mongolia','MN','MNG')
    ,(147,'Montenegro','ME','MNE')
    ,(148,'Montserrat','MS','MSR')
    ,(149,'Morocco','MA','MAR')
    ,(150,'Mozambique','MZ','MOZ')
    ,(151,'Myanmar (Burma)','MM','MMR')
    ,(152,'Namibia','NA','NAM')
    ,(153,'Nauru','NR','NRU')
    ,(154,'Nepal','NP','NPL')
    ,(155,'Netherlands','NL','NLD')
    ,(156,'New Caledonia','NC','NCL')
    ,(157,'New Zealand','NZ','NZL')
    ,(158,'Nicaragua','NI','NIC')
    ,(159,'Niger','NE','NER')
    ,(160,'Nigeria','NG','NGA')
    ,(161,'Niue','NU','NIU')
    ,(162,'Norfolk Island','NF','NFK')
    ,(163,'North Korea','KP','PRK')
    ,(164,'Northern Mariana Islands','MP','MNP')
    ,(165,'Norway','NO','NOR')
    ,(166,'Oman','OM','OMN')
    ,(167,'Pakistan','PK','PAK')
    ,(168,'Palau','PW','PLW')
    ,(169,'Palestine','PS','PSE')
    ,(170,'Panama','PA','PAN')
    ,(171,'Papua New Guinea','PG','PNG')
    ,(172,'Paraguay','PY','PRY')
    ,(173,'Peru','PE','PER')
    ,(174,'Phillipines','PH','PHL')
    ,(175,'Pitcairn','PN','PCN')
    ,(176,'Poland','PL','POL')
    ,(177,'Portugal','PT','PRT')
    ,(178,'Puerto Rico','PR','PRI')
    ,(179,'Qatar','QA','QAT')
    ,(180,'Reunion','RE','REU')
    ,(181,'Romania','RO','ROU')
    ,(182,'Russia','RU','RUS')
    ,(183,'Rwanda','RW','RWA')
    ,(184,'Saint Barthelemy','BL','BLM')
    ,(185,'Saint Helena','SH','SHN')
    ,(186,'Saint Kitts and Nevis','KN','KNA')
    ,(187,'Saint Lucia','LC','LCA')
    ,(188,'Saint Martin','MF','MAF')
    ,(189,'Saint Pierre and Miquelon','PM','SPM')
    ,(190,'Saint Vincent and the Grenadines','VC','VCT')
    ,(191,'Samoa','WS','WSM')
    ,(192,'San Marino','SM','SMR')
    ,(193,'Sao Tome and Principe','ST','STP')
    ,(194,'Saudi Arabia','SA','SAU')
    ,(195,'Senegal','SN','SEN')
    ,(196,'Serbia','RS','SRB')
    ,(197,'Seychelles','SC','SYC')
    ,(198,'Sierra Leone','SL','SLE')
    ,(199,'Singapore','SG','SGP')
    ,(200,'Sint Maarten','SX','SXM')
    ,(201,'Slovakia','SK','SVK')
    ,(202,'Slovenia','SI','SVN')
    ,(203,'Solomon Islands','SB','SLB')
    ,(204,'Somalia','SO','SOM')
    ,(205,'South Africa','ZA','ZAF')
    ,(206,'South Georgia and the South Sandwich Islands','GS','SGS')
    ,(207,'South Korea','KR','KOR')
    ,(208,'South Sudan','SS','SSD')
    ,(209,'Spain','ES','ESP')
    ,(210,'Sri Lanka','LK','LKA')
    ,(211,'Sudan','SD','SDN')
    ,(212,'Suriname','SR','SUR')
    ,(213,'Svalbard and Jan Mayen','SJ','SJM')
    ,(214,'Swaziland','SZ','SWZ')
    ,(215,'Sweden','SE','SWE')
    ,(216,'Switzerland','CH','CHE')
    ,(217,'Syria','SY','SYR')
    ,(218,'Taiwan','TW','TWN')
    ,(219,'Tajikistan','TJ','TJK')
    ,(220,'Tanzania','TZ','TZA')
    ,(221,'Thailand','TH','THA')
    ,(222,'Timor-Leste (East Timor)','TL','TLS')
    ,(223,'Togo','TG','TGO')
    ,(224,'Tokelau','TK','TKL')
    ,(225,'Tonga','TO','TON')
    ,(226,'Trinidad and Tobago','TT','TTO')
    ,(227,'Tunisia','TN','TUN')
    ,(228,'Turkey','TR','TUR')
    ,(229,'Turkmenistan','TM','TKM')
    ,(230,'Turks and Caicos Islands','TC','TCA')
    ,(231,'Tuvalu','TV','TUV')
    ,(232,'Uganda','UG','UGA')
    ,(233,'Ukraine','UA','UKR')
    ,(234,'United Arab Emirates','AE','ARE')
    ,(235,'United Kingdom','GB','GBR')
    ,(236,'United States','US','USA')
    ,(237,'United States Minor Outlying Islands','UM','UMI')
    ,(238,'Uruguay','UY','URY')
    ,(239,'Uzbekistan','UZ','UZB')
    ,(240,'Vanuatu','VU','VUT')
    ,(241,'Vatican City','VA','VAT')
    ,(242,'Venezuela','VE','VEN')
    ,(243,'Vietnam','VN','VNM')
    ,(244,'Virgin Islands, British','VG','VGB')
    ,(245,'Virgin Islands, US','VI','VIR')
    ,(246,'Wallis and Futuna','WF','WLF')
    ,(247,'Western Sahara','EH','ESH')
    ,(248,'Yemen','YE','YEM')
    ,(249,'Zambia','ZM','ZMB')
    ,(250,'Zimbabwe','ZW','ZWE');
    

    For more details please visit: http://www.dbrnd.com/2015/05/insert-script-for-all-countries/

    0 讨论(0)
  • 2021-02-13 05:10

    You can get the t-sql script that creates a "countries" table and populates the table with ISO list of countries inlcuding the Numerical Code of the country, the name of the country both in lower case letters and upper case letters, the ISO ALPHA-3 code and the ISO 3166-1-alpha-2 code from: http://blog.xsql.com/2012/10/t-sql-list-of-countries.html

    0 讨论(0)
  • 2021-02-13 05:14

    Here you go.

    Just modify the script to suit your schema.

    0 讨论(0)
  • 2021-02-13 05:17

    To all the lazy fellows out there like me, Here's the solution. Hope it helps anyone stuck with the same issue.

    Countries list with ISO Codes.

    -first the countries table

    CREATE TABLE dbo.Countries
    (
    CountryID INT IDENTITY NOT NULL PRIMARY KEY,
    ISO_Code NCHAR(2) NOT NULL,
    CountryName NVARCHAR(256) NOT NULL
    )
    GO
    

    -second add a button on a page and for the onclick event paste the following but replace the connection string with your's. Also check the quotes for e.g. ('US') after pasting. (I learned it the hard way!) Just to be sure use Quick Replace in VS-2010 which you will find in Edit menu

    string sqlConnString = "ADD YOUR CONNECTION STRING HERE";
    protected void Button1_Click(object sender, EventArgs e)
        {
            string query = "INSERT INTO dbo.Countries (ISO_Code, CountryName) " +
                "VALUES ('AF', 'Afghanistan')," +
                "('AX', 'Aland Islands')," +
                "('AT', 'Austria')," +
                "('AZ', 'Azerbaijan')," +
                "('BS', 'Bahamas')," +
                "('BH', 'Bahrain')," +
                "('BD', 'Bangladesh')," +
                "('BB', 'Barbados')," +
                "('BY', 'Belarus')," +
                "('BE', 'Belgium')," +
                "('BZ', 'Belize')," +
                "('BJ', 'Benin')," +
                "('BM', 'Bermuda')," +
                "('BT', 'Bhutan')," +
                "('BO', 'Bolivia')," +
                "('BA', 'Bosnia and Herzegovina')," +
                "('BW', 'Botswana')," +
                "('BV', 'Bouvet Island')," +
                "('BR', 'Brazil')," +
                "('IO', 'British Indian Ocean Territory')," +
                "('BN', 'Brunei Darussalam')," +
                "('BG', 'Bulgaria')," +
                "('BF', 'Burkina Faso')," +
                "('BI', 'Burundi')," +
                "('KH', 'Cambodia')," +
                "('CM', 'Cameroon')," +
                "('CA', 'Canada')," +
                "('CV', 'Cape Verde')," +
                "('KY', 'Cayman Islands')," +
                "('CF', 'Central African Republic')," +
                "('TD', 'Chad')," +
                "('CL', 'Chile')," +
                "('CN', 'China')," +
                "('CX', 'Christmas Island')," +
                "('CC', 'Cocos Keeling Islands')," +
                "('CO', 'Colombia')," +
                "('KM', 'Comoros')," +
                "('CG', 'Congo')," +
                "('CD', 'Congo, The Democratic Republic of The')," +
                "('CK', 'Cook Islands')," +
                "('CR', 'Costa Rica')," +
                "('CI', 'Cote Divoire')," +
                "('HR', 'Croatia')," +
                "('CU', 'Cuba')," +
                "('CY', 'Cyprus')," +
                "('CZ', 'Czech Republic')," +
                "('DK', 'Denmark')," +
                "('DJ', 'Djibouti')," +
                "('DM', 'Dominica')," +
                "('DO', 'Dominican Republic')," +
                "('EC', 'Ecuador')," +
                "('EG', 'Egypt')," +
                "('SV', 'El Salvador')," +
                "('GQ', 'Equatorial Guinea')," +
                "('ER', 'Eritrea')," +
                "('EE', 'Estonia')," +
                "('ET', 'Ethiopia')," +
                "('FK', 'Falkland Islands Malvinas')," +
                "('FO', 'Faroe Islands')," +
                "('FJ', 'Fiji')," +
                "('FI', 'Finland')," +
                "('FR', 'France')," +
                "('GF', 'French Guiana')," +
                "('PF', 'French Polynesia')," +
                "('TF', 'French Southern Territories')," +
                "('GA', 'Gabon')," +
                "('GM', 'Gambia')," +
                "('GE', 'Georgia')," +
                "('DE', 'Germany')," +
                "('GH', 'Ghana')," +
                "('GI', 'Gibraltar')," +
                "('GR', 'Greece')," +
                "('GL', 'Greenland')," +
                "('GD', 'Grenada')," +
                "('GP', 'Guadeloupe')," +
                "('GU', 'Guam')," +
                "('GT', 'Guatemala')," +
                "('GG', 'Guernsey')," +
                "('GN', 'Guinea')," +
                "('GW', 'Guinea-bissau')," +
                "('GY', 'Guyana')," +
                "('HT', 'Haiti')," +
                "('HM', 'Heard Island and Mcdonald Islands')," +
                "('VA', 'Holy See Vatican City State')," +
                "('HN', 'Honduras')," +
                "('HK', 'Hong Kong')," +
                "('HU', 'Hungary')," +
                "('IS', 'Iceland')," +
                "('IN', 'India')," +
                "('ID', 'Indonesia')," +
                "('IR', 'Iran, Islamic Republic of')," +
                "('IQ', 'Iraq')," +
                "('IE', 'Ireland')," +
                "('IM', 'Isle of Man')," +
                "('IL', 'Israel')," +
                "('IT', 'Italy')," +
                "('JM', 'Jamaica')," +
                "('JP', 'Japan')," +
                "('JE', 'Jersey')," +
                "('JO', 'Jordan')," +
                "('KZ', 'Kazakhstan')," +
                "('KE', 'Kenya')," +
                "('KI', 'Kiribati')," +
                "('KP', 'Korea, Democratic Peoples Republic of')," +
                "('KR', 'Korea, Republic of')," +
                "('KW', 'Kuwait')," +
                "('KG', 'Kyrgyzstan')," +
                "('LA', 'Lao Peoples Democratic Republic')," +
                "('LV', 'Latvia')," +
                "('LB', 'Lebanon')," +
                "('LS', 'Lesotho')," +
                "('LR', 'Liberia')," +
                "('LY', 'Libyan Arab Jamahiriya')," +
                "('LI', 'Liechtenstein')," +
                "('LT', 'Lithuania')," +
                "('LU', 'Luxembourg')," +
                "('MO', 'Macao')," +
                "('MK', 'Macedonia, The Former Yugoslav Republic of')," +
                "('MG', 'Madagascar')," +
                "('MW', 'Malawi')," +
                "('MY', 'Malaysia')," +
                "('MV', 'Maldives')," +
                "('ML', 'Mali')," +
                "('MT', 'Malta')," +
                "('MH', 'Marshall Islands')," +
                "('MQ', 'Martinique')," +
                "('MR', 'Mauritania')," +
                "('MU', 'Mauritius')," +
                "('YT', 'Mayotte')," +
                "('MX', 'Mexico')," +
                "('FM', 'Micronesia, Federated States of')," +
                "('MD', 'Moldova, Republic of')," +
                "('MC', 'Monaco')," +
                "('MN', 'Mongolia')," +
                "('ME', 'Montenegro')," +
                "('MS', 'Montserrat')," +
                "('MA', 'Morocco')," +
                "('MZ', 'Mozambique')," +
                "('MM', 'Myanmar')," +
                "('NA', 'Namibia')," +
                "('NR', 'Nauru')," +
                "('NP', 'Nepal')," +
                "('NL', 'Netherlands')," +
                "('AN', 'Netherlands Antilles')," +
                "('NC', 'New Caledonia')," +
                "('NZ', 'New Zealand')," +
                "('NI', 'Nicaragua')," +
                "('NE', 'Niger')," +
                "('NG', 'Nigeria')," +
                "('NU', 'Niue')," +
                "('NF', 'Norfolk Island')," +
                "('MP', 'Northern Mariana Islands')," +
                "('NO', 'Norway')," +
                "('OM', 'Oman')," +
                "('PK', 'Pakistan')," +
                "('PW', 'Palau')," +
                "('PS', 'Palestinian Territory, Occupied')," +
                "('PA', 'Panama')," +
                "('PG', 'Papua New Guinea')," +
                "('PY', 'Paraguay')," +
                "('PE', 'Peru')," +
                "('PH', 'Philippines')," +
                "('PN', 'Pitcairn')," +
                "('PL', 'Poland')," +
                "('PT', 'Portugal')," +
                "('PR', 'Puerto Rico')," +
                "('QA', 'Qatar')," +
                "('RE', 'Reunion')," +
                "('RO', 'Romania')," +
                "('RU', 'Russian Federation')," +
                "('RW', 'Rwanda')," +
                "('SH', 'Saint Helena')," +
                "('KN', 'Saint Kitts and Nevis')," +
                "('LC', 'Saint Lucia')," +
                "('PM', 'Saint Pierre and Miquelon')," +
                "('VC', 'Saint Vincent and The Grenadines')," +
                "('WS', 'Samoa')," +
                "('SM', 'San Marino')," +
                "('ST', 'Sao Tome and Principe')," +
                "('SA', 'Saudi Arabia')," +
                "('SN', 'Senegal')," +
                "('RS', 'Serbia')," +
                "('SC', 'Seychelles')," +
                "('SL', 'Sierra Leone')," +
                "('SG', 'Singapore')," +
                "('SK', 'Slovakia')," +
                "('SI', 'Slovenia')," +
                "('SB', 'Solomon Islands')," +
                "('SO', 'Somalia')," +
                "('ZA', 'South Africa')," +
                "('GS', 'South Georgia and The South Sandwich Islands')," +
                "('ES', 'Spain')," +
                "('LK', 'Sri Lanka')," +
                "('SD', 'Sudan')," +
                "('SR', 'Suriname')," +
                "('SJ', 'Svalbard and Jan Mayen')," +
                "('SZ', 'Swaziland')," +
                "('SE', 'Sweden')," +
                "('CH', 'Switzerland')," +
                "('SY', 'Syrian Arab Republic')," +
                "('TW', 'Taiwan, Province of China')," +
                "('TJ', 'Tajikistan')," +
                "('TZ', 'Tanzania, United Republic of')," +
                "('TH', 'Thailand')," +
                "('TL', 'Timor-leste')," +
                "('TG', 'Togo')," +
                "('TK', 'Tokelau')," +
                "('TO', 'Tonga')," +
                "('TT', 'Trinidad and Tobago')," +
                "('TN', 'Tunisia')," +
                "('TR', 'Turkey')," +
                "('TM', 'Turkmenistan')," +
                "('TC', 'Turks and Caicos Islands')," +
                "('TV', 'Tuvalu')," +
                "('UG', 'Uganda')," +
                "('UA', 'Ukraine')," +
                "('AE', 'United Arab Emirates')," +
                "('GB', 'United Kingdom')," +
                "('US', 'United States')," +
                "('UM', 'United States Minor Outlying Islands')," +
                "('UY', 'Uruguay')," +
                "('UZ', 'Uzbekistan')," +
                "('VU', 'Vanuatu')," +
                "('VE', 'Venezuela')," +
                "('VN', 'Viet Nam')," +
                "('VG', 'Virgin Islands, British')," +
                "('VI', 'Virgin Islands, U.S.')," +
                "('WF', 'Wallis and Futuna')," +
                "('EH', 'Western Sahara')," +
                "('YE', 'Yemen')," +
                "('ZM', 'Zambia')," +
                "('ZW', 'Zimbabwe')";
    
            using (SqlConnection conn = new SqlConnection(sqlConnString))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(query, conn);
                cmd.ExecuteNonQuery();
            }
        }
    

    And that's it populate your drop-down lists from this data.

    0 讨论(0)
提交回复
热议问题