IF EXISTS(SELECT * FROM sys.columns WHERE [name] = N'GovermentWareType' AND [object_id] = OBJECT_ID(N'Products'))
BEGIN
  ALTER TABLE Products 
  ALTER COLUMN GovermentWareType INT NULL

  EXEC sp_RENAME 'Products.GovermentWareType' , 'FK_GovermentWareTypeId', 'COLUMN'
END

IF EXISTS(SELECT * FROM sys.columns WHERE [name] = N'GovermentWareType' AND [object_id] = OBJECT_ID(N'RoomTypes'))
BEGIN
  ALTER TABLE RoomTypes DROP COLUMN GovermentWareType
END

if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GovermentWareType]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[GovermentWareType](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[ExternalWareNumber] [varchar](50) NOT NULL,
	[Name] [varchar](50) NOT NULL,
	[SortNumber] [int] NOT NULL,
 CONSTRAINT [PK_GovermentWareType] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)
) ON [PRIMARY]

GO

SET NOCOUNT ON
IF NOT EXISTS(SELECT * FROM GovermentWareType WITH (NOLOCK) WHERE ExternalWareNumber = '10001')
  INSERT INTO GovermentWareType (ExternalWareNumber, Name, SortNumber) VALUES ('10001', 'Halvdagsmøde uden morgenmad', 1)
IF NOT EXISTS(SELECT * FROM GovermentWareType WITH (NOLOCK) WHERE ExternalWareNumber = '10002')
  INSERT INTO GovermentWareType (ExternalWareNumber, Name, SortNumber) VALUES ('10002', 'Halvdagsmøde med morgenmad', 2)
IF NOT EXISTS(SELECT * FROM GovermentWareType WITH (NOLOCK) WHERE ExternalWareNumber = '10003')
  INSERT INTO GovermentWareType (ExternalWareNumber, Name, SortNumber) VALUES ('10003', 'Heldagsmøde uden middag', 3)
IF NOT EXISTS(SELECT * FROM GovermentWareType WITH (NOLOCK) WHERE ExternalWareNumber = '10004')
  INSERT INTO GovermentWareType (ExternalWareNumber, Name, SortNumber) VALUES ('10004', 'Heldagsmøde med middag à 2 retter', 4)
IF NOT EXISTS(SELECT * FROM GovermentWareType WITH (NOLOCK) WHERE ExternalWareNumber = '10005')
  INSERT INTO GovermentWareType (ExternalWareNumber, Name, SortNumber) VALUES ('10005', 'Heldagsmøde med middag à 3 retter', 5)
IF NOT EXISTS(SELECT * FROM GovermentWareType WITH (NOLOCK) WHERE ExternalWareNumber = '10006')
  INSERT INTO GovermentWareType (ExternalWareNumber, Name, SortNumber) VALUES ('10006', 'Helsdagsmøde med overnatning og middag à 2 retter', 6)
IF NOT EXISTS(SELECT * FROM GovermentWareType WITH (NOLOCK) WHERE ExternalWareNumber = '10007')
  INSERT INTO GovermentWareType (ExternalWareNumber, Name, SortNumber) VALUES ('10007', 'Heldagsmøde med overnatning og middag à 3 retter', 7)
IF NOT EXISTS(SELECT * FROM GovermentWareType WITH (NOLOCK) WHERE ExternalWareNumber = '10008')
  INSERT INTO GovermentWareType (ExternalWareNumber, Name, SortNumber) VALUES ('10008', '12-12 møde med overnatning og middag à 2 retter', 8)
IF NOT EXISTS(SELECT * FROM GovermentWareType WITH (NOLOCK) WHERE ExternalWareNumber = '10009')
  INSERT INTO GovermentWareType (ExternalWareNumber, Name, SortNumber) VALUES ('10009', '12-12 møde med overnatning og middag à 3 retter', 9)