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



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

GO




