How To Remove "Log In" link from BlogEngine.Net Sites



TODO:

Have you ever wanted to get rid of the "log in" link that appears on sites created with BlogEngine.Net?

 

SOLUTION:

1.  Edit the PageMenu.cs page that is located in BlogEngine.Net\App_Code\Controls\PageMenu.cs

2.  Chagne the BindPages() method to be the code below.

3.  Build BlogEngine.Net, and copy the DLLs to your "bin" folder.

 

private HtmlGenericControl BindPages()
{
            // recursivly get all children of the root page
            HtmlGenericControl ul = GetChildren(Guid.Empty);

            // items that will be appended to the end of menu list
            AddMenuItem(ul, Contact, "~/contact.aspx");

            if (Security.IsAuthenticated)
            {
                AddMenuItem(ul, Logoff, "~/Account/login.aspx?logoff");
            }
            else
            {
                //AddMenuItem(ul, Logon, "~/Account/login.aspx");
            }

            return ul;
}

 

 

NOTES:

All I did was comment out the else so that "log in" never appears.  If you navigate to http://site/account/login.aspx, you can log in.  In the event you do log in, you will get a "log out" link, but will never get the "log in" link.

How To Get The Value Of A Lookup Field Column In SharePoint



TODO:

Have you ever had a lookup column, and you want to get its value programatically using C#?

1.  I have a column that is called, Task Id.  

2.  "Task Id" in #1, is a lookup to the "ID" column of a list called "Tasks"

3.  I have an event receiver that needs to get the "Task Id" from the form.

 

SOLUTION:

 

//my event receiver code....
public override void ItemAdded(SPItemEventProperties properties)
{
     SPFieldLookup lookupField = properties.ListItem.Fields["Task ID"] as SPFieldLookup;
     SPFieldLookupValue taskIdVal = null;

     object obj = properties.ListItem["Task ID"];
     if (lookupField != null)
          taskIdVal = lookupField.GetFieldValue(obj.ToString()) as SPFieldLookupValue;

     string taskId = taskIdVal.LookupValue;
}

 

 

NOTES:

There are no notes on this topic.

How To Remove "Log In" Menu Item From BlogEngine.net Site



TODO:

Have you ever wanted to remove the log in link that is in the menu of sites created with BlogEngine.Net?

 

SOLUTION:

Download the source for BlogEngine.Net.  

Open in Visual Studio

Open BlogEngine.Net\App_Code\Controls\PageMenu.cs

Look for the method "HtmlGenericControl BindPages()"

Comment out "AddMenuItem" in the ELSE of the Security.IsAuthenticated check.

Build the solution, and deploy the new DLL.

Now you will never see "log in", and will see "log off" only if you login by going directly to the log ing page.  ( yoursite.com/Account/Login.aspx )

 

 

private HtmlGenericControl BindPages()
{
            // recursivly get all children of the root page
            HtmlGenericControl ul = GetChildren(Guid.Empty);

            // items that will be appended to the end of menu list
            AddMenuItem(ul, Contact, "~/contact.aspx");

            if (Security.IsAuthenticated)
            {
                AddMenuItem(ul, Logoff, "~/Account/login.aspx?logoff");
            }
            else
            {
                //AddMenuItem(ul, Logon, "~/Account/login.aspx");
            }

            return ul;
}

 

 

NOTES:

There are no notes on this topic

How To Fix The NativeStack Error In SharePoint 2010 When Deploying An Event Receiver



TODO:

Have you ever had the dreaded "Error occurred in deployment step 'Activate Features': <nativehr>0x80070002</nativehr><nativestack></nativestack>" error when deploying an Event Receiver that targets a specific list?

 

SOLUTION:

In my case, this was caused by an invalid 'ListURL' setting in my elements.xml file.  Be sure the 'Site URL' property of your project points to the site that the List resides.  If this is pointed to the level above, the list will not be found, and you will get the error above.  ListURL needs to be 'Lists/'{your list name}  ex. List/Customers, thus you see why it is important for the Site URL to be set properly.

 

NOTES:

There are no notes on this topic.

How To Configure Unknown File Types For Download In IIS (ex. ".dmg" files)



TODO:

Have you ever tried to allow uses to download a file, for instance a .dmg file, but your users could not do so?  This happens because the .dmg file type is not defined in the MIME Type Settings in IIS.

 

SOLUTION:

  1. Open IIS
  2. Click on the site affected.
  3. Click "Mime Types"
  4. Click "Add"
  5. Enter ".dmg" in the file extension text box (no quotes)
  6. Enter "file/download" in the MIME type text box (no quotes)
  7. Click "OK" and you are done.  Your users will now be ble to download .dmg files from your web server.

 

NOTES:

These instructions are for IIS version 7

How To Nicely Format An XML Document



TODO:

Have you have XML in a text editor such as notepad, and the formatting is non existent.  Sometimes it is nice to have it indented for use in a PDF or Word Document.  Well, after instaling a few tools, it turns out it can be done in Visual Studio quite easily.

 

SOLUTION:

Open the document in Visual Studio (I use 2010).  Hit CTRL-A, then CTRL-K, then CTRL-F

Your XML will now look nice and indented.

 

NOTES:

There are no note on this topic.

Serialize A List<T> Produces Flat Results C#



TODO:

Have you serialzied an object that had a List<T> as a property, and the list is flattened when it gets to XML?

 

SOLUTION:

This occurs if you have the property marked as [XmlElement("name")].  instead mark the property as [XmlArray("name")] and you will get parent child nodes for your List<T>

 

NOTES:

There are no notes on this topic

How To INIT CAP Data In T-SQL



TODO:

Have you ever wanted to convert the data in a column to INIT CAP?  For example you have data 'TEST DATA' and you want to change it to 'Test Data'?

 

SOLUTION:

 

CREATE FUNCTION dbo.fCapFirst(@pcIn NVARCHAR(4000))
RETURNS NVARCHAR(4000) AS
BEGIN
DECLARE @i		INT
,  @cWork		NVARCHAR(4000)

SET @cWork = Upper(Left(@pcIn, 1)) + Lower(SubString(@pcIn, 2, 4000))

SET @i = PatIndex('%[^0-9A-Za-z][a-z]%'
,  @cWork COLLATE Latin1_General_BIN)

WHILE 0 < @i
   BEGIN
      SET @cWork = Left(@cWork, @i) 
+        Upper(SubString(@cWork, 1 + @i, 1)) + SubString(@cWork, 2 + @i, 4000)
      SET @i = PatIndex('%[^0-9A-Za-z][a-z]%'
,        @cWork COLLATE Latin1_General_BIN)
   END

RETURN @cWork
END
GO

 

NOTES:

This solution was posted by user Pat Phelan on this site. 

To run issue this command:  update MyTable set Mycolumn= dbo.fCapFirst(Mycolumn)

How To Populate A Table With US State Data



TODO:

Have you ever wanted to have a table of US states and not have to type them in.  If so, run the SQL below.  It assumes you have a table named 'State', with fields of StateId (identity), Abbreviation, and Name.

 

SOLUTION:

insert into state(abbreviation,name) values('AL','Alabama');
insert into state(abbreviation,name) values('AK','Alaska');
insert into state(abbreviation,name) values('AS','American Somoa');
insert into state(abbreviation,name) values('AZ','Arizona');
insert into state(abbreviation,name) values('AR','Arkansas');
insert into state(abbreviation,name) values('AE','Armed Forces Africa, Canada, Middle East, Europe');
insert into state(abbreviation,name) values('AA','Armed Forces America (except Canada)');
insert into state(abbreviation,name) values('AP','Armed Forces Pacific');
insert into state(abbreviation,name) values('CA','California');
insert into state(abbreviation,name) values('CO','Colorado');
insert into state(abbreviation,name) values('CT','Connecticut');
insert into state(abbreviation,name) values('DE','Delaware');
insert into state(abbreviation,name) values('DC','District of Columbia');
insert into state(abbreviation,name) values('FM','Federated States of Micronesia');
insert into state(abbreviation,name) values('FL','Florida');
insert into state(abbreviation,name) values('GA','Georgia');
insert into state(abbreviation,name) values('GU','Guam');
insert into state(abbreviation,name) values('HI','Hawaii');
insert into state(abbreviation,name) values('ID','Idaho');
insert into state(abbreviation,name) values('IL','Illinois');
insert into state(abbreviation,name) values('IN','Indiana');
insert into state(abbreviation,name) values('IA','Iowa');
insert into state(abbreviation,name) values('KS','Kansas');
insert into state(abbreviation,name) values('KY','Kentucky');
insert into state(abbreviation,name) values('LA','Louisiana');
insert into state(abbreviation,name) values('ME','Maine');
insert into state(abbreviation,name) values('MH','Marshall Islands');
insert into state(abbreviation,name) values('MD','Maryland');
insert into state(abbreviation,name) values('MA','Massachusetts');
insert into state(abbreviation,name) values('MI','Michigan');
insert into state(abbreviation,name) values('MN','Minnesota');
insert into state(abbreviation,name) values('MS','Mississippi');
insert into state(abbreviation,name) values('MO','Missouri');
insert into state(abbreviation,name) values('MT','Montana');
insert into state(abbreviation,name) values('NE','Nebraska');
insert into state(abbreviation,name) values('NV','Nevada');
insert into state(abbreviation,name) values('NH','New Hampshire');
insert into state(abbreviation,name) values('NJ','New Jersey');
insert into state(abbreviation,name) values('NM','New Mexico');
insert into state(abbreviation,name) values('NY','New York');
insert into state(abbreviation,name) values('NC','North Carolina');
insert into state(abbreviation,name) values('ND','North Dakota');
insert into state(abbreviation,name) values('MP','Northern Mariana Islands');
insert into state(abbreviation,name) values('OH','Ohio');
insert into state(abbreviation,name) values('OK','Oklahoma');
insert into state(abbreviation,name) values('OR','Oregon');
insert into state(abbreviation,name) values('PM','Palau');
insert into state(abbreviation,name) values('PA','Pennsylvania');
insert into state(abbreviation,name) values('PR','Puerto Rico');
insert into state(abbreviation,name) values('RI','Rhode Island');
insert into state(abbreviation,name) values('SC','South Carolina');
insert into state(abbreviation,name) values('SD','South Dakota');
insert into state(abbreviation,name) values('TN','Tennessee');
insert into state(abbreviation,name) values('TX','Texas');
insert into state(abbreviation,name) values('VI','U.S. Virgin Islands');
insert into state(abbreviation,name) values('UT','Utah');
insert into state(abbreviation,name) values('VT','Vermont');
insert into state(abbreviation,name) values('VA','Virginia');
insert into state(abbreviation,name) values('WA','Washington');
insert into state(abbreviation,name) values('WV','West Virginia');
insert into state(abbreviation,name) values('WI','Wisconsin');
insert into state(abbreviation,name) values('WY','Wyoming');

 

NOTES:

There are no notes on this topic.

How To Populate A Table With ISO 3166-1 Country Data



TODO:

Did you ever need a reference table of ISO country data?  Is so, create a table called 'Country', and add an identity column named 'CountryId', IsoCode, and Name, then execute this SQL. 

 

SOLUTION:

 

insert into country(IsoCode, Name) Values ('AF','AFGHANISTAN');
insert into country(IsoCode, Name) Values ('AX','åLAND ISLANDS');
insert into country(IsoCode, Name) Values ('AL','ALBANIA');
insert into country(IsoCode, Name) Values ('DZ','ALGERIA');
insert into country(IsoCode, Name) Values ('AS','AMERICAN SAMOA');
insert into country(IsoCode, Name) Values ('AD','ANDORRA');
insert into country(IsoCode, Name) Values ('AO','ANGOLA');
insert into country(IsoCode, Name) Values ('AI','ANGUILLA');
insert into country(IsoCode, Name) Values ('AQ','ANTARCTICA');
insert into country(IsoCode, Name) Values ('AG','ANTIGUA AND BARBUDA');
insert into country(IsoCode, Name) Values ('AR','ARGENTINA');
insert into country(IsoCode, Name) Values ('AM','ARMENIA');
insert into country(IsoCode, Name) Values ('AW','ARUBA');
insert into country(IsoCode, Name) Values ('AU','AUSTRALIA');
insert into country(IsoCode, Name) Values ('AT','AUSTRIA');
insert into country(IsoCode, Name) Values ('AZ','AZERBAIJAN');
insert into country(IsoCode, Name) Values ('BS','BAHAMAS');
insert into country(IsoCode, Name) Values ('BH','BAHRAIN');
insert into country(IsoCode, Name) Values ('BD','BANGLADESH');
insert into country(IsoCode, Name) Values ('BB','BARBADOS');
insert into country(IsoCode, Name) Values ('BY','BELARUS');
insert into country(IsoCode, Name) Values ('BE','BELGIUM');
insert into country(IsoCode, Name) Values ('BZ','BELIZE');
insert into country(IsoCode, Name) Values ('BJ','BENIN');
insert into country(IsoCode, Name) Values ('BM','BERMUDA');
insert into country(IsoCode, Name) Values ('BT','BHUTAN');
insert into country(IsoCode, Name) Values ('BO','BOLIVIA');
insert into country(IsoCode, Name) Values ('BQ','BONAIRE');
insert into country(IsoCode, Name) Values ('BA','BOSNIA AND HERZEGOVINA');
insert into country(IsoCode, Name) Values ('BW','BOTSWANA');
insert into country(IsoCode, Name) Values ('BV','BOUVET ISLAND');
insert into country(IsoCode, Name) Values ('BR','BRAZIL');
insert into country(IsoCode, Name) Values ('IO','BRITISH INDIAN OCEAN TERRITORY');
insert into country(IsoCode, Name) Values ('BN','BRUNEI DARUSSALAM');
insert into country(IsoCode, Name) Values ('BG','BULGARIA');
insert into country(IsoCode, Name) Values ('BF','BURKINA FASO');
insert into country(IsoCode, Name) Values ('BI','BURUNDI');
insert into country(IsoCode, Name) Values ('KH','CAMBODIA');
insert into country(IsoCode, Name) Values ('CM','CAMEROON');
insert into country(IsoCode, Name) Values ('CA','CANADA');
insert into country(IsoCode, Name) Values ('CV','CAPE VERDE');
insert into country(IsoCode, Name) Values ('KY','CAYMAN ISLANDS');
insert into country(IsoCode, Name) Values ('CF','CENTRAL AFRICAN REPUBLIC');
insert into country(IsoCode, Name) Values ('TD','CHAD');
insert into country(IsoCode, Name) Values ('CL','CHILE');
insert into country(IsoCode, Name) Values ('CN','CHINA');
insert into country(IsoCode, Name) Values ('CX','CHRISTMAS ISLAND');
insert into country(IsoCode, Name) Values ('CC','COCOS (KEELING) ISLANDS');
insert into country(IsoCode, Name) Values ('CO','COLOMBIA');
insert into country(IsoCode, Name) Values ('KM','COMOROS');
insert into country(IsoCode, Name) Values ('CG','CONGO');
insert into country(IsoCode, Name) Values ('CD','THE DEMOCRATIC REPUBLIC OF THE CONGO');
insert into country(IsoCode, Name) Values ('CK','COOK ISLANDS');
insert into country(IsoCode, Name) Values ('CR','COSTA RICA');
insert into country(IsoCode, Name) Values ('CI','CôTE D''IVOIRE');
insert into country(IsoCode, Name) Values ('HR','CROATIA');
insert into country(IsoCode, Name) Values ('CU','CUBA');
insert into country(IsoCode, Name) Values ('CW','CURAçAO');
insert into country(IsoCode, Name) Values ('CY','CYPRUS');
insert into country(IsoCode, Name) Values ('CZ','CZECH REPUBLIC');
insert into country(IsoCode, Name) Values ('DK','DENMARK');
insert into country(IsoCode, Name) Values ('DJ','DJIBOUTI');
insert into country(IsoCode, Name) Values ('DM','DOMINICA');
insert into country(IsoCode, Name) Values ('DO','DOMINICAN REPUBLIC');
insert into country(IsoCode, Name) Values ('EC','ECUADOR');
insert into country(IsoCode, Name) Values ('EG','EGYPT');
insert into country(IsoCode, Name) Values ('SV','EL SALVADOR');
insert into country(IsoCode, Name) Values ('GQ','EQUATORIAL GUINEA');
insert into country(IsoCode, Name) Values ('ER','ERITREA');
insert into country(IsoCode, Name) Values ('EE','ESTONIA');
insert into country(IsoCode, Name) Values ('ET','ETHIOPIA');
insert into country(IsoCode, Name) Values ('FK','FALKLAND ISLANDS (MALVINAS)');
insert into country(IsoCode, Name) Values ('FO','FAROE ISLANDS');
insert into country(IsoCode, Name) Values ('FJ','FIJI');
insert into country(IsoCode, Name) Values ('FI','FINLAND');
insert into country(IsoCode, Name) Values ('FR','FRANCE');
insert into country(IsoCode, Name) Values ('GF','FRENCH GUIANA');
insert into country(IsoCode, Name) Values ('PF','FRENCH POLYNESIA');
insert into country(IsoCode, Name) Values ('TF','FRENCH SOUTHERN TERRITORIES');
insert into country(IsoCode, Name) Values ('GA','GABON');
insert into country(IsoCode, Name) Values ('GM','GAMBIA');
insert into country(IsoCode, Name) Values ('GE','GEORGIA');
insert into country(IsoCode, Name) Values ('DE','GERMANY');
insert into country(IsoCode, Name) Values ('GH','GHANA');
insert into country(IsoCode, Name) Values ('GI','GIBRALTAR');
insert into country(IsoCode, Name) Values ('GR','GREECE');
insert into country(IsoCode, Name) Values ('GL','GREENLAND');
insert into country(IsoCode, Name) Values ('GD','GRENADA');
insert into country(IsoCode, Name) Values ('GP','GUADELOUPE');
insert into country(IsoCode, Name) Values ('GU','GUAM');
insert into country(IsoCode, Name) Values ('GT','GUATEMALA');
insert into country(IsoCode, Name) Values ('GG','GUERNSEY');
insert into country(IsoCode, Name) Values ('GN','GUINEA');
insert into country(IsoCode, Name) Values ('GW','GUINEA-BISSAU');
insert into country(IsoCode, Name) Values ('GY','GUYANA');
insert into country(IsoCode, Name) Values ('HT','HAITI');
insert into country(IsoCode, Name) Values ('HM','HEARD ISLAND AND MCDONALD ISLANDS');
insert into country(IsoCode, Name) Values ('VA','HOLY SEE (VATICAN CITY STATE)');
insert into country(IsoCode, Name) Values ('HN','HONDURAS');
insert into country(IsoCode, Name) Values ('HK','HONG KONG');
insert into country(IsoCode, Name) Values ('HU','HUNGARY');
insert into country(IsoCode, Name) Values ('IS','ICELAND');
insert into country(IsoCode, Name) Values ('IN','INDIA');
insert into country(IsoCode, Name) Values ('ID','INDONESIA');
insert into country(IsoCode, Name) Values ('IR','IRAN');
insert into country(IsoCode, Name) Values ('IQ','IRAQ');
insert into country(IsoCode, Name) Values ('IE','IRELAND');
insert into country(IsoCode, Name) Values ('IM','ISLE OF MAN');
insert into country(IsoCode, Name) Values ('IL','ISRAEL');
insert into country(IsoCode, Name) Values ('IT','ITALY');
insert into country(IsoCode, Name) Values ('JM','JAMAICA');
insert into country(IsoCode, Name) Values ('JP','JAPAN');
insert into country(IsoCode, Name) Values ('JE','JERSEY');
insert into country(IsoCode, Name) Values ('JO','JORDAN');
insert into country(IsoCode, Name) Values ('KZ','KAZAKHSTAN');
insert into country(IsoCode, Name) Values ('KE','KENYA');
insert into country(IsoCode, Name) Values ('KI','KIRIBATI');
insert into country(IsoCode, Name) Values ('KP','DEMOCRATIC PEOPLE''S REPUBLIC OF KOREA');
insert into country(IsoCode, Name) Values ('KR','REPUBLIC OF KOREA');
insert into country(IsoCode, Name) Values ('KW','KUWAIT');
insert into country(IsoCode, Name) Values ('KG','KYRGYZSTAN');
insert into country(IsoCode, Name) Values ('LA','LAO PEOPLE''S DEMOCRATIC REPUBLIC');
insert into country(IsoCode, Name) Values ('LV','LATVIA');
insert into country(IsoCode, Name) Values ('LB','LEBANON');
insert into country(IsoCode, Name) Values ('LS','LESOTHO');
insert into country(IsoCode, Name) Values ('LR','LIBERIA');
insert into country(IsoCode, Name) Values ('LY','LIBYA');
insert into country(IsoCode, Name) Values ('LI','LIECHTENSTEIN');
insert into country(IsoCode, Name) Values ('LT','LITHUANIA');
insert into country(IsoCode, Name) Values ('LU','LUXEMBOURG');
insert into country(IsoCode, Name) Values ('MO','MACAO');
insert into country(IsoCode, Name) Values ('MK','MACEDONIA');
insert into country(IsoCode, Name) Values ('MG','MADAGASCAR');
insert into country(IsoCode, Name) Values ('MW','MALAWI');
insert into country(IsoCode, Name) Values ('MY','MALAYSIA');
insert into country(IsoCode, Name) Values ('MV','MALDIVES');
insert into country(IsoCode, Name) Values ('ML','MALI');
insert into country(IsoCode, Name) Values ('MT','MALTA');
insert into country(IsoCode, Name) Values ('MH','MARSHALL ISLANDS');
insert into country(IsoCode, Name) Values ('MQ','MARTINIQUE');
insert into country(IsoCode, Name) Values ('MR','MAURITANIA');
insert into country(IsoCode, Name) Values ('MU','MAURITIUS');
insert into country(IsoCode, Name) Values ('YT','MAYOTTE');
insert into country(IsoCode, Name) Values ('MX','MEXICO');
insert into country(IsoCode, Name) Values ('FM','MICRONESIA');
insert into country(IsoCode, Name) Values ('MD','MOLDOVA');
insert into country(IsoCode, Name) Values ('MC','MONACO');
insert into country(IsoCode, Name) Values ('MN','MONGOLIA');
insert into country(IsoCode, Name) Values ('ME','MONTENEGRO');
insert into country(IsoCode, Name) Values ('MS','MONTSERRAT');
insert into country(IsoCode, Name) Values ('MA','MOROCCO');
insert into country(IsoCode, Name) Values ('MZ','MOZAMBIQUE');
insert into country(IsoCode, Name) Values ('MM','MYANMAR');
insert into country(IsoCode, Name) Values ('NA','NAMIBIA');
insert into country(IsoCode, Name) Values ('NR','NAURU');
insert into country(IsoCode, Name) Values ('NP','NEPAL');
insert into country(IsoCode, Name) Values ('NL','NETHERLANDS');
insert into country(IsoCode, Name) Values ('NC','NEW CALEDONIA');
insert into country(IsoCode, Name) Values ('NZ','NEW ZEALAND');
insert into country(IsoCode, Name) Values ('NI','NICARAGUA');
insert into country(IsoCode, Name) Values ('NE','NIGER');
insert into country(IsoCode, Name) Values ('NG','NIGERIA');
insert into country(IsoCode, Name) Values ('NU','NIUE');
insert into country(IsoCode, Name) Values ('NF','NORFOLK ISLAND');
insert into country(IsoCode, Name) Values ('MP','NORTHERN MARIANA ISLANDS');
insert into country(IsoCode, Name) Values ('NO','NORWAY');
insert into country(IsoCode, Name) Values ('OM','OMAN');
insert into country(IsoCode, Name) Values ('PK','PAKISTAN');
insert into country(IsoCode, Name) Values ('PW','PALAU');
insert into country(IsoCode, Name) Values ('PS','PALESTINIAN TERRITORY');
insert into country(IsoCode, Name) Values ('PA','PANAMA');
insert into country(IsoCode, Name) Values ('PG','PAPUA NEW GUINEA');
insert into country(IsoCode, Name) Values ('PY','PARAGUAY');
insert into country(IsoCode, Name) Values ('PE','PERU');
insert into country(IsoCode, Name) Values ('PH','PHILIPPINES');
insert into country(IsoCode, Name) Values ('PN','PITCAIRN');
insert into country(IsoCode, Name) Values ('PL','POLAND');
insert into country(IsoCode, Name) Values ('PT','PORTUGAL');
insert into country(IsoCode, Name) Values ('PR','PUERTO RICO');
insert into country(IsoCode, Name) Values ('QA','QATAR');
insert into country(IsoCode, Name) Values ('RE','RéUNION');
insert into country(IsoCode, Name) Values ('RO','ROMANIA');
insert into country(IsoCode, Name) Values ('RU','RUSSIAN FEDERATION');
insert into country(IsoCode, Name) Values ('RW','RWANDA');
insert into country(IsoCode, Name) Values ('BL','SAINT BARTHéLEMY');
insert into country(IsoCode, Name) Values ('SH','SAINT HELENA');
insert into country(IsoCode, Name) Values ('KN','SAINT KITTS AND NEVIS');
insert into country(IsoCode, Name) Values ('LC','SAINT LUCIA');
insert into country(IsoCode, Name) Values ('MF','SAINT MARTIN (FRENCH PART)');
insert into country(IsoCode, Name) Values ('PM','SAINT PIERRE AND MIQUELON');
insert into country(IsoCode, Name) Values ('VC','SAINT VINCENT AND THE GRENADINES');
insert into country(IsoCode, Name) Values ('WS','SAMOA');
insert into country(IsoCode, Name) Values ('SM','SAN MARINO');
insert into country(IsoCode, Name) Values ('ST','SAO TOME AND PRINCIPE');
insert into country(IsoCode, Name) Values ('SA','SAUDI ARABIA');
insert into country(IsoCode, Name) Values ('SN','SENEGAL');
insert into country(IsoCode, Name) Values ('RS','SERBIA');
insert into country(IsoCode, Name) Values ('SC','SEYCHELLES');
insert into country(IsoCode, Name) Values ('SL','SIERRA LEONE');
insert into country(IsoCode, Name) Values ('SG','SINGAPORE');
insert into country(IsoCode, Name) Values ('SX','SINT MAARTEN (DUTCH PART)');
insert into country(IsoCode, Name) Values ('SK','SLOVAKIA');
insert into country(IsoCode, Name) Values ('SI','SLOVENIA');
insert into country(IsoCode, Name) Values ('SB','SOLOMON ISLANDS');
insert into country(IsoCode, Name) Values ('SO','SOMALIA');
insert into country(IsoCode, Name) Values ('ZA','SOUTH AFRICA');
insert into country(IsoCode, Name) Values ('GS','SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS');
insert into country(IsoCode, Name) Values ('SS','SOUTH SUDAN');
insert into country(IsoCode, Name) Values ('ES','SPAIN');
insert into country(IsoCode, Name) Values ('LK','SRI LANKA');
insert into country(IsoCode, Name) Values ('SD','SUDAN');
insert into country(IsoCode, Name) Values ('SR','SURINAME');
insert into country(IsoCode, Name) Values ('SJ','SVALBARD AND JAN MAYEN');
insert into country(IsoCode, Name) Values ('SZ','SWAZILAND');
insert into country(IsoCode, Name) Values ('SE','SWEDEN');
insert into country(IsoCode, Name) Values ('CH','SWITZERLAND');
insert into country(IsoCode, Name) Values ('SY','SYRIAN ARAB REPUBLIC');
insert into country(IsoCode, Name) Values ('TW','TAIWAN');
insert into country(IsoCode, Name) Values ('TJ','TAJIKISTAN');
insert into country(IsoCode, Name) Values ('TZ','TANZANIA');
insert into country(IsoCode, Name) Values ('TH','THAILAND');
insert into country(IsoCode, Name) Values ('TL','TIMOR-LESTE');
insert into country(IsoCode, Name) Values ('TG','TOGO');
insert into country(IsoCode, Name) Values ('TK','TOKELAU');
insert into country(IsoCode, Name) Values ('TO','TONGA');
insert into country(IsoCode, Name) Values ('TT','TRINIDAD AND TOBAGO');
insert into country(IsoCode, Name) Values ('TN','TUNISIA');
insert into country(IsoCode, Name) Values ('TR','TURKEY');
insert into country(IsoCode, Name) Values ('TM','TURKMENISTAN');
insert into country(IsoCode, Name) Values ('TC','TURKS AND CAICOS ISLANDS');
insert into country(IsoCode, Name) Values ('TV','TUVALU');
insert into country(IsoCode, Name) Values ('UG','UGANDA');
insert into country(IsoCode, Name) Values ('UA','UKRAINE');
insert into country(IsoCode, Name) Values ('AE','UNITED ARAB EMIRATES');
insert into country(IsoCode, Name) Values ('GB','UNITED KINGDOM');
insert into country(IsoCode, Name) Values ('US','UNITED STATES');
insert into country(IsoCode, Name) Values ('UM','UNITED STATES MINOR OUTLYING ISLANDS');
insert into country(IsoCode, Name) Values ('UY','URUGUAY');
insert into country(IsoCode, Name) Values ('UZ','UZBEKISTAN');
insert into country(IsoCode, Name) Values ('VU','VANUATU');
insert into country(IsoCode, Name) Values ('VE','VENEZUELA');
insert into country(IsoCode, Name) Values ('VN','VIET NAM');
insert into country(IsoCode, Name) Values ('VG','BRITISH VIRGIN ISLANDS');
insert into country(IsoCode, Name) Values ('VI','U.S. VIRGIN ISLANDS');
insert into country(IsoCode, Name) Values ('WF','WALLIS AND FUTUNA');
insert into country(IsoCode, Name) Values ('EH','WESTERN SAHARA');
insert into country(IsoCode, Name) Values ('YE','YEMEN');
insert into country(IsoCode, Name) Values ('ZM','ZAMBIA');
insert into country(IsoCode, Name) Values ('ZW','ZIMBABWE');

 

NOTES:

This solution assumes you have a table name 'Country', with columns of 'CountryId (identity), Name, and IsoCode