IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects(NOLOCK) 
    INNER JOIN SysColumns(NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'SoldRoomType'
    WHERE SysObjects.Name = 'ROOMBOOKINGSTATUSINSALE'
)
begin
  IF EXISTS (SELECT name FROM SysIndexes(NOLOCK) WHERE name = 
            'PK_RoomBookingStatusInsale')
  begin
	ALTER TABLE ROOMBOOKINGSTATUSINSALE
	Drop CONSTRAINT [PK_ROOMBOOKINGSTATUSINSALE]
  end

  ALTER TABLE ROOMBOOKINGSTATUSINSALE ADD SoldRoomType SMALLINT NOT NULL DEFAULT 0

  ALTER TABLE ROOMBOOKINGSTATUSINSALE WITH NOCHECK 
  ADD CONSTRAINT [PK_RoomBookingStatusInsale] PRIMARY KEY CLUSTERED 
  (
	[DateStamp] DESC,
	[HotelNumber] ASC,
	[SoldRoomType] ASC
  ) ON [PRIMARY]
end
GO
