IF NOT EXISTS (SELECT * FROM dbo.sysobjects (NOLOCK) WHERE id = object_id(N'[dbo].[TemplateSendSchedule]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
	CREATE TABLE [dbo].[TemplateSendSchedule](
		[TemplateType] [int] NOT NULL,
		[ScheduleType] [int] NOT NULL,
		[NumberOfDays] [int] NULL,
		[RecurringType] INT NULL
	 CONSTRAINT [PK_TemplateSendSchedule] PRIMARY KEY CLUSTERED 
	(
		[TemplateType] ASC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
	) ON [PRIMARY]
END
ELSE

	IF EXISTS(SELECT * from sys.columns c (nolock)
		Inner join sys.Tables t ON c.object_id = t.object_id and t.name = 'TemplateSendSchedule'
		where c.name = 'FK_TemplateNumber')
	BEGIN
		DROP TABLE [dbo].[TemplateSendSchedule]

		CREATE TABLE [dbo].[TemplateSendSchedule](
		[TemplateType] [int] NOT NULL,
		[ScheduleType] [int] NOT NULL,
		[NumberOfDays] [int] NULL,
		[RecurringType] INT NULL
		 CONSTRAINT [PK_TemplateSendSchedule] PRIMARY KEY CLUSTERED 
		(
			[TemplateType] ASC
		)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
		) ON [PRIMARY]
	END


