SET NOCOUNT ON

DECLARE @Unknown INT
DECLARE @Dan INT
DECLARE @VISA INT
DECLARE @Master INT
DECLARE @Amex INT
DECLARE @Diners INT
DECLARE @JCB INT
DECLARE @Maestro INT

SELECT @Unknown = CreditCardTypeId FROM CreditCardType WITH (NOLOCK) WHERE Number = 99
SELECT @Dan = CreditCardTypeId FROM CreditCardType WITH (NOLOCK) WHERE Number = 8
SELECT @VISA = CreditCardTypeId FROM CreditCardType WITH (NOLOCK) WHERE Number = 1
SELECT @Master = CreditCardTypeId FROM CreditCardType WITH (NOLOCK) WHERE Number = 2
SELECT @Amex = CreditCardTypeId FROM CreditCardType WITH (NOLOCK) WHERE Number = 4
SELECT @Diners = CreditCardTypeId FROM CreditCardType WITH (NOLOCK) WHERE Number = 5
SELECT @JCB = CreditCardTypeId FROM CreditCardType WITH (NOLOCK) WHERE Number = 12
SELECT @Maestro = CreditCardTypeId FROM CreditCardType WITH (NOLOCK) WHERE Number = 16

IF NOT EXISTS (SELECT * FROM TypeNoName WITH(NOLOCK) WHERE Type_FK = 2)
BEGIN
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('AMEX', 'American Express', 2, 1, @Amex)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('AMEX(DK)', 'American Express (DK)', 2, 2, @Amex)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('AMEX(SE)', 'American Express (SE)', 2, 3, @Amex)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('DIN', 'Diners Club (DK)', 2, 4, @Diners)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('DK', 'Dankort', 2, 5, @Dan)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('ELEC', 'VISA Electron', 2, 6, @VISA)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('JCB', 'JCB', 2, 7, @JCB)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('LIC(DK)', 'LIC kort (DK)', 2, 8, @Unknown)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('LIC(SE)', 'LIC kort (SE)', 2, 9, @Unknown)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('MC', 'Mastercard', 2, 10, @Master)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('MC(DK)', 'Mastercard (DK)', 2, 11, @Master)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('MC(SE)', 'Mastercard (SE)', 2, 12, @Master)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('MC(YX)', 'YX Mastercard', 2, 13, @Master)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('MPO_Nets', 'MobilePay Online', 2, 14, @Unknown)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('MTRO', 'Maestro', 2, 15, @Maestro)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('MTRO(DK)', 'Maestro (DK)', 2, 16, @Maestro)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('MTRO(UK)', 'Maestro (UK)', 2, 17, @Maestro)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('MTRO(SOLO)', 'Solo', 2, 18, @Maestro)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('MTRO(SE)', 'Maestro (SE)', 2, 19, @Maestro)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('NSBK', 'Nordea Bankkort', 2, 20, @Unknown)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('OESBK', 'Östgöta Enskilda Bankkort', 2, 21, @Unknown)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('SBSBK', 'Skandiabanken Bankkort', 2, 22, @Unknown)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('SEB_KOBK', 'SEB Köpkort', 2, 23, @Unknown)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('SEBSBK', 'SEB Bankkort', 2, 24, @Unknown)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('SHB_KB', 'Handelsbanken Köpkort', 2, 25, @Unknown)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('V-DK', 'VISA-Dankort', 2, 26, @VISA)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('VISA', 'VISA', 2, 27, @VISA)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('VISA(DK)', 'VISA (DK)', 2, 28, @VISA)
  INSERT INTO TypeNoName (Name, Description, Type_FK, Number, FK_NoName) VALUES ('VISA(SE)', 'VISA (SE)', 2, 29, @VISA)
END