DECLARE @GroupName varchar(30)
DECLARE @SortNumber int
DECLARE @GroupCode varchar(3)

DECLARE @CountryName varchar(30)
DECLARE @CountryCode varchar(3)
DECLARE @CurrencyCode varchar(3)
DECLARE @CurrencyName varchar(30)

DECLARE @CountryGroupNumber int

DECLARE @OtherEurope int
DECLARE @OtherAfrica int
DECLARE @OtherAmerica int
DECLARE @OtherAsia int
DECLARE @OtherWorld int
DECLARE @OtherMiddleEast INT
DECLARE @Denmark int
DECLARE @Finland int

DECLARE @TheCountryCode varchar(3)

SELECT @TheCountryCode = CountryCode FROM Countries WITH (NOLOCK) 
WHERE CountryNumber = (SELECT KeyValue FROM HotelSetup WITH (NOLOCK) WHERE SearchKey = 'COUNTRYCODE')
  
IF @TheCountryCode = 'F'
BEGIN
  CREATE TABLE #TempGroups (CountryName     VarChar(30) NOT NULL,
                          GroupSortNumber Int         NOT NULL,
                          CountryCode     varchar(3)  NOT NULL)

  INSERT INTO #TempGroups VALUES ('France',1,'000')
  INSERT INTO #TempGroups VALUES ('Allemagne',2,'109')
  INSERT INTO #TempGroups VALUES ('Belgique',3,'131')
  INSERT INTO #TempGroups VALUES ('Espagne',4,'134')
  INSERT INTO #TempGroups VALUES ('Etats-Unis',5,'404') --USA
  INSERT INTO #TempGroups VALUES ('Italie',6,'127')
  INSERT INTO #TempGroups VALUES ('Japon',7,'217')
  INSERT INTO #TempGroups VALUES ('Pays-Bas',8,'135') -- Nederland
  INSERT INTO #TempGroups VALUES ('Portugal',9,'139')
  INSERT INTO #TempGroups VALUES ('Royaume-Uni',10,'132')  -- Storbritanien
  INSERT INTO #TempGroups VALUES ('Suisse',11,'140')
  INSERT INTO #TempGroups VALUES ('Autriche',12,'110')
  INSERT INTO #TempGroups VALUES ('Bulgarie',13,'111')
  INSERT INTO #TempGroups VALUES ('Chypre',14,'254')
  INSERT INTO #TempGroups VALUES ('Croatie',15,'119')
  INSERT INTO #TempGroups VALUES ('Danemark',16,'101')
  INSERT INTO #TempGroups VALUES ('Estonie',17,'106')
  INSERT INTO #TempGroups VALUES ('Finlande',18,'105')
  INSERT INTO #TempGroups VALUES ('Gréce',19,'126')
  INSERT INTO #TempGroups VALUES ('Hongrie',20,'112')
  INSERT INTO #TempGroups VALUES ('Irlande',21,'136')
  INSERT INTO #TempGroups VALUES ('Islande',22,'102')
  INSERT INTO #TempGroups VALUES ('Lettonie',23,'107')
  INSERT INTO #TempGroups VALUES ('Lituanie',24,'108')
  INSERT INTO #TempGroups VALUES ('Luxembourg',25,'137')
  INSERT INTO #TempGroups VALUES ('Malte',26,'144')
  INSERT INTO #TempGroups VALUES ('Norvége',27,'103')
  INSERT INTO #TempGroups VALUES ('Pologne',28,'122')
  INSERT INTO #TempGroups VALUES ('République Tchéque',29,'116')
  INSERT INTO #TempGroups VALUES ('Roumanie',30,'114')
  INSERT INTO #TempGroups VALUES ('Russie',31,'123')
  INSERT INTO #TempGroups VALUES ('Slovaquie',32,'117')
  INSERT INTO #TempGroups VALUES ('Slovénie',33,'145')
  INSERT INTO #TempGroups VALUES ('Suéde',34,'104')
  INSERT INTO #TempGroups VALUES ('Turquie',35,'208')
  INSERT INTO #TempGroups VALUES ('Autres pays d''europe',36,'040') -- Other europe
  INSERT INTO #TempGroups VALUES ('Algérie, Maroc, Tunisie',37,'027')
  INSERT INTO #TempGroups VALUES ('Autres pays africains',38,'028') -- other africa
  INSERT INTO #TempGroups VALUES ('Canada',39,'401')
  INSERT INTO #TempGroups VALUES ('Amérique centrale et du Sud',40,'030') -- Central and south america
  INSERT INTO #TempGroups VALUES ('Proche et Moyen Orient',41,'031') -- middle east
  INSERT INTO #TempGroups VALUES ('Chine',42,'216')
  INSERT INTO #TempGroups VALUES ('Australie',43,'501')
  INSERT INTO #TempGroups VALUES ('Asie, Océanie',44,'039')-- other asia + oceanic

  DECLARE db_cur CURSOR FOR
    SELECT * FROM #TempGroups WITH (nolock)
  OPEN db_cur 
	   
	FETCH NEXT FROM db_cur INTO @GroupName, @SortNumber, @GroupCode
	    
	WHILE @@fetch_status = 0 
	BEGIN
	  IF @SortNumber = 1   -- Frankrig 
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Frankrig'
	  IF @SortNumber = 2   -- Tyskland
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Tyskland'
	  IF @SortNumber = 3   -- Belgien 
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Belgien'
	  IF @SortNumber = 4   -- Spanien
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Spanien'
	  IF @SortNumber = 5   -- USA
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'USA'
	  IF @SortNumber = 6   -- Italien 
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Italien'
	  IF @SortNumber = 7   -- Japan
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Japan'
	  IF @SortNumber = 8   -- Holland
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Holland'
	  IF @SortNumber = 9   -- Portugal
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Portugal'
	  IF @SortNumber = 10   -- Storbritanien 
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Storbritanien'
	  IF @SortNumber = 11   -- Schweiz 
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Schweiz'
	  IF @SortNumber = 12   -- Østrig 
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Østrig'
	  IF @SortNumber = 13   -- Bulagarien
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Bulgarien' 
	  IF @SortNumber = 14   -- Cypern 
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Cypern' 
	  IF @SortNumber = 15   -- Kroatien
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Kroatien' 
	  IF @SortNumber = 16   -- Danmark 
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Danmark' 
	  IF @SortNumber = 17   -- Estland
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Estland'
	  IF @SortNumber = 18   -- Finland
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Finland'
	  IF @SortNumber = 19   -- Grækenland
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Grækenland'
	  IF @SortNumber = 20   -- Ungarn
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Ungarn'
	  IF @SortNumber = 21   -- Irland
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Irland'
	  IF @SortNumber = 22   -- Island
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Island'
	  IF @SortNumber = 23   -- Letland
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Letland'
	  IF @SortNumber = 24   -- Litauen
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Litauen'
	  IF @SortNumber = 25   -- Luxemborg
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Luxemborg'
	  IF @SortNumber = 26   -- Malta
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Malta'
	  IF @SortNumber = 27   -- Norge
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Norge'
	  IF @SortNumber = 28   -- Polen
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Polen'
	  IF @SortNumber = 29   -- Tjekkiet
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Tjekkiet'
	  IF @SortNumber = 30   -- Rumænien
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Rumænien'
	  IF @SortNumber = 31   -- Rusland
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Rusland'
	  IF @SortNumber = 32   -- Slovakiet
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Slovakiet'
	  IF @SortNumber = 33   -- Slovenien
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName = 'Slovenien'
	  IF @SortNumber = 34   -- Sverige
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName = 'Sverige'
	  IF @SortNumber = 35   -- Tyrkiet
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName = 'Tyrkiet'
	  IF @SortNumber = 36   -- Øvrige europa
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName LIKE '%Europa i %vrigt%' OR GroupCode = 'EO' OR GroupName LIKE '%Andre europæiske lande%' OR GroupName = 'Europa ellers'
	  IF @SortNumber = 37   -- Algeriet
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName = 'Algeriet'
	  IF @SortNumber = 38   -- Andre amerikanske lande 
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName LIKE '%Andre amerikanske lande%' OR GroupName ='Afrika'
	  IF @SortNumber = 39   -- Canada
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName = 'Canada'
	  IF @SortNumber = 40   -- Sydamerikanske lande
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName LIKE '%Amerika i %vrigt' OR GroupCode = 'AO' OR GroupName LIKE '%Andre afrikanske lande%' OR GroupName = 'Amerika ellers'
--	  IF @SortNumber = 41   -- Mellemøsten
--	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName LIKE '%Folkerepublikken Kina%' OR GroupName = 'Kina'
	  IF @SortNumber = 42   -- Folkerepublikken Kina
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName LIKE '%Folkerepublikken Kina%' OR GroupName = 'Kina'
	  IF @SortNumber = 43   -- Australien
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode  WHERE GroupName = 'Australien'
	  IF @SortNumber = 44   -- Andre asiatiske lande 
	    UPDATE CountryGroups SET GroupName = @GroupName, GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName LIKE '%Syd%stasian i %vrigt%' OR GroupName LIKE '%Syd%stasien i %vrigt%' OR GroupCode = 'SO' OR GroupName = 'Andre land'
    IF @@RowCount > 0
    BEGIN
	    PRINT 'Rename: ' + @GroupName
	    FETCH NEXT FROM db_cur INTO @GroupName, @SortNumber, @GroupCode
	    CONTINUE
    END
	  IF NOT EXISTS (SELECT GroupName FROM CountryGroups WITH (NOLOCK) WHERE GroupName = @GroupName) 
	  BEGIN
	    PRINT 'Insert: ' + @GroupName
	    INSERT INTO CountryGroups (GroupName, GroupSortNumber, GroupCode) VALUES (@GroupName,@SortNumber,@GroupCode)
	  END
	  ELSE
	  BEGIN
	    UPDATE CountryGroups SET GroupSortNumber = @SortNumber, GroupCode = @GroupCode WHERE GroupName = @GroupName
	    PRINT 'Update: ' + @GroupName
	  END
	  
    FETCH NEXT FROM db_cur INTO @GroupName, @SortNumber, @GroupCode
  END

  CREATE TABLE #TempCountries (CountryName     varchar(30) NOT NULL,
                               CountryCode     varchar(3)  NOT NULL,
                               CurrencyCode    varchar(3)  NOT NULL,
                               CurrencyName    varchar(30) NOT NULL)

	--Hent Hvilket nr de enkelte grupper har fået.
	SELECT @OtherEurope = GroupNumber FROM CountryGroups WITH (NOLOCK) WHERE GroupSortNumber = 36
	SELECT @OtherAfrica = GroupNumber FROM CountryGroups WITH (NOLOCK) WHERE GroupSortNumber = 38
	SELECT @OtherAmerica = GroupNumber FROM CountryGroups WITH (NOLOCK) WHERE GroupSortNumber = 40
	SELECT @OtherAsia = GroupNumber FROM CountryGroups WITH (NOLOCK) WHERE GroupSortNumber = 44
	SELECT @OtherMiddleEast = GroupNumber FROM CountryGroups WITH (NOLOCK) WHERE GroupSortNumber = 41
	
  --hent liste over alle andre lande og del op i korrekte grupper
  DECLARE db_cur2 CURSOR FOR
    SELECT CountryName, CountryGroupNumber FROM Countries WITH (nolock)
  OPEN db_cur2 
 
  FETCH NEXT FROM db_cur2 INTO @CountryName, @CountryGroupNumber
  
  WHILE @@fetch_status = 0 
  BEGIN
    IF @CountryName = 'Angola' or @CountryName = 'Benin' or @CountryName = 'Botswana' or @CountryName = 'Burkina Faso' or 
       @CountryName = 'Burundi' or @CountryName = 'Cameroon' or @CountryName = 'Cape Verde' or @CountryName = 'Central African Republic' or @CountryName = 'Chad' or 
       @CountryName = 'Comoros' or @CountryName = 'Cote dIvoire' or @CountryName = 'Equatorial Guinea' or @CountryName = 'Eritrea' or 
       @CountryName = 'Ethiopia' or @CountryName = 'Gabon' or @CountryName = 'Gambia' or @CountryName = 'Ghana' or @CountryName = 'Guinea-Bissau' or 
       @CountryName = 'Guinea' or @CountryName = 'Kenya' or @CountryName = 'Madagascar' or @CountryName = 'Malawi' or 
       @CountryName = 'Mali' or @CountryName = 'Mauritania' or @CountryName = 'Mauritius' or @CountryName = 'Mozambique' or 
       @CountryName = 'Namibia' or @CountryName = 'Nigeria' or @CountryName = 'Niger' or @CountryName = 'Republic of the Congo' or @CountryName = 'Rwanda' or 
       @CountryName = 'Sao Tome and Principe' or @CountryName = 'Senegal' or @CountryName = 'Seychelles' or @CountryName = 'Sierra Leone' or @CountryName = 'Somalia' or 
       @CountryName = 'Swaziland' or @CountryName = 'Tanzania' or @CountryName = 'Togo' or 
       @CountryName = 'Uganda' or @CountryName = 'Zambia' or @CountryName = 'Zimbabwe' or @CountryName = 'Congo' or @CountryName = 'Tunesia' 
    BEGIN
      -- Africa
      UPDATE Countries SET CountryGroupNumber = @OtherAfrica WHERE CountryName = @CountryName 
    END

    IF @CountryName = 'Egypt' OR @CountryName = 'Iran' OR @CountryName = 'Iraq' OR @CountryName = 'Israel' OR @CountryName = 'Jordan' OR
       @CountryName = 'Kuwait' OR @CountryName = 'Lebanon' or @CountryName = 'Liberia' or @CountryName = 'Libya' or @CountryName = 'Morocco' OR
       @CountryName = 'Oman' OR @CountryName = 'Qatar' OR @CountryName = 'Saudi Arabia' or @CountryName = 'Sudan' or @CountryName = 'Syria' or
       @CountryName = 'Tunisia' OR @CountryName = 'United Arab Emirates' OR @CountryName = 'Yemen'  
     BEGIN
      -- Mellemøsten
      UPDATE Countries SET CountryGroupNumber = @OtherMiddleEast WHERE CountryName = @CountryName 
    END

    IF @CountryName = 'Armenia' OR @CountryName = 'ORAzerbaijan' OR @CountryName = 'Bangladesh' OR @CountryName = 'Brunei' OR @CountryName = 'Cambodia' OR
       @CountryName = 'Georgia' OR @CountryName = 'Hong Kong' OR @CountryName = 'India' OR @CountryName = 'Indonesia' OR @CountryName = 'Kazakhstan' OR
       @CountryName = 'Laos' OR @CountryName = 'Macao' OR @CountryName = 'Malaysia' OR @CountryName = 'Maldives' OR @CountryName = 'Mongolia' OR
       @CountryName = 'Myanmar' OR @CountryName = 'Nepal' OR @CountryName = 'North Korea' OR @CountryName = 'Pakistan' OR
       @CountryName = 'Philippines' OR @CountryName = 'Singapore' OR @CountryName = 'Sri Lanka' OR
       @CountryName = 'Taiwan' OR @CountryName = 'Tajikistan' OR @CountryName = 'Oman' OR @CountryName = 'Thailand' OR
       @CountryName = 'Vietnam' OR @CountryName = 'Sri Lanca' OR
       @CountryName = 'Federated States of Micronesia' OR @CountryName = 'Fiji' OR @CountryName = 'Kiribati' OR @CountryName = 'Marshall Islands' OR
       @CountryName = 'Nauru' OR @CountryName = 'New Zealand' OR @CountryName = 'Palau' OR @CountryName = 'Papua New Guinea' OR @CountryName = 'Samoa' OR
       @CountryName = 'Solomon Islands' OR @CountryName = 'Tonga' OR @CountryName = 'Tuvalu' OR @CountryName = 'Vanuatu'
    BEGIN
      -- Asia
      UPDATE Countries SET CountryGroupNumber = @OtherAsia WHERE CountryName = @CountryName 
    END

    IF @CountryName = 'Albania' or @CountryName = 'Andorra' or @CountryName = 'Belarus' or @CountryName = 'Bosnia and Herzegovina' or 
       @CountryName = 'Liechtenstein' or @CountryName = 'Macedonia' or @CountryName = 'Moldova' or
       @CountryName = 'San Marino' or @CountryName = 'Vatican City' or @CountryName = 'Yugoslavia' OR @CountryName = 'Euro' or @CountryName = 'Vatican'
    BEGIN
      -- Europe 
      UPDATE Countries SET CountryGroupNumber = @OtherEurope WHERE CountryName = @CountryName 
    END

    IF @CountryName = 'Belize' OR @CountryName = 'Costa Rica' OR @CountryName = 'Cuba' OR @CountryName = 'Dominican Republic' OR @CountryName = 'El Salvador' OR
       @CountryName = 'Guatemala' OR @CountryName = 'Haiti' OR @CountryName = 'Honduras' OR @CountryName = 'Jamaica' OR @CountryName = 'Mexico' OR
       @CountryName = 'Nicaragua' OR @CountryName = 'Panama' OR @CountryName = 'Argentina' OR @CountryName = 'Bolivia' OR @CountryName = 'Chile' OR
       @CountryName = 'Colombia' OR @CountryName = 'Ecuador' OR @CountryName = 'French Guiana' OR @CountryName = 'Guyana' OR @CountryName = 'Paraguay' OR
       @CountryName = 'Peru' OR @CountryName = 'Suriname' OR @CountryName = 'Uruguay' OR @CountryName = 'Venezuela' OR @CountryName = 'Equador'
    BEGIN
      --America
      UPDATE Countries SET CountryGroupNumber = @OtherAmerica WHERE CountryName = @CountryName 
    END

    FETCH NEXT FROM db_cur2 INTO @CountryName, @CountryGroupNumber
  END

  CLOSE db_cur
  DEALLOCATE db_cur
  CLOSE db_cur2
  DEALLOCATE db_cur2

  DROP TABLE #TempGroups
  DROP TABLE #TempCountries

  UPDATE Countries SET CountryGroupNumber = @OtherEurope WHERE (CountryCode = 'FO' OR CountryCode = 'GL' OR CountryCode = 'UA')
  DELETE CountryGroups WHERE (GroupCode = 'FO' OR GroupCode = 'GL' OR GroupCode = 'UA')

  UPDATE Countries SET CountryGroupNumber = @OtherAfrica WHERE (CountryCode = 'ZA')
  DELETE CountryGroups WHERE (GroupCode = 'ZA')

  UPDATE Countries SET CountryGroupNumber = @OtherAmerica WHERE (CountryCode = 'BR')
  DELETE CountryGroups WHERE (GroupCode = 'BR')

  UPDATE Countries SET CountryGroupNumber = @OtherAsia WHERE (CountryCode = 'KR')
  DELETE CountryGroups WHERE (GroupCode = 'KR')

  DELETE Countries WHERE (CountryCode = 'OAL' OR CountryCode = 'OOL' OR CountryCode = 'OT')
  DELETE CountryGroups WHERE (GroupCode = 'OAL' OR GroupCode = 'OOL')

/*
  SELECT * FROM CountryGroups (nolock) ORDER BY GroupSortNumber
  SELECT * FROM Countries (nolock) ORDER BY SortNumber
*/
END
