IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'ForceOnCashierID'
    WHERE SysObjects.Name = 'DEPARTMENTS'
)
  Alter table DEPARTMENTS add ForceOnCashierID bit NULL
GO

IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'UseQuickLogin'
    WHERE SysObjects.Name = 'DEPARTMENTS'
)
  Alter table DEPARTMENTS add UseQuickLogin bit NULL
GO


IF NOT EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'QuickUserChange'
    WHERE SysObjects.Name = 'DEPARTMENTS'
)
  Alter table DEPARTMENTS add QuickUserChange bit NULL
GO


Update DEPARTMENTS 
SET ForceOnCashierID = coalesce((select KeyValue 
                                from HotelSetup
                                where SearchKey='ForceOnCashierID'), 0)
WHERE ForceOnCashierID is null

GO

Update DEPARTMENTS 
SET UseQuickLogin = coalesce((select KeyValue 
                              from   HotelSetup
                              where  SearchKey='UseQuickLogIn'), 0)
WHERE UseQuickLogin is null


Go

Update DEPARTMENTS 
SET QuickUserChange = coalesce((select KeyValue 
                                from HotelSetup
                                where SearchKey='QuickUserChange'), 0)
WHERE QuickUserChange is null
Go


