SET NOCOUNT ON
IF EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'Group'
    WHERE SysObjects.Name = 'WareGroupBillSortTypesXTab'
)
  EXEC dbo.sp_rename @objname=N'[dbo].[WareGroupBillSortTypesXTab].[Group]', @newname=N'GroupIndex', @objtype=N'COLUMN'
GO

SET NOCOUNT ON
IF EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'MenuWare'
    WHERE SysObjects.Name = 'Ware'
)
  EXEC dbo.sp_rename @objname=N'[dbo].[Ware].[MenuWare]', @newname=N'IsMenuWare', @objtype=N'COLUMN'
GO

IF EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'FK_RefereneNumber'
    WHERE SysObjects.Name = 'ReservationSendLog'
)
	EXEC sp_rename 'ReservationSendLog.FK_RefereneNumber', 'FK_ReferenceNumber', 'COLUMN'	
GO

IF EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'ReferenceNumber'
    WHERE SysObjects.Name = 'ReservationSendLetter'
)
BEGIN
	EXEC sp_rename 'ReservationSendLetter.ReferenceNumber', 'FK_ReferenceNumber', 'COLUMN'
	EXEC sp_rename 'ReservationSendLetter.GuestNumber', 'FK_GuestNumber', 'COLUMN'
END

IF EXISTS
(
  SELECT SysColumns.Name 
  FROM SysObjects WITH (NOLOCK) 
    INNER JOIN SysColumns WITH (NOLOCK) ON SysColumns.Id = SysObjects.ID 
    AND SysColumns.Name = 'NumberOfDays'
    WHERE SysObjects.Name = 'TemplateSendSchedule'
)
	EXEC sp_rename 'TemplateSendSchedule.NumberOfDays', 'RecurringEvery', 'COLUMN'	
GO
