IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[MailGroup]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[MailGroup](
	[ID] [int] NOT NULL,
	[MailGroupName] [varchar](255) NULL,
    CONSTRAINT [PK_MailGroup] PRIMARY KEY CLUSTERED ([ID] ASC)) ON [PRIMARY]
END

IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[MailGroupMailAddressesXtab]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
  CREATE TABLE [dbo].[MailGroupMailAddressesXtab](
	[ID] [int] NOT NULL,
	[FK_MailGroupID] [int] NOT NULL,
	[FK_Number] [int] NULL,
	[Type] [int] NOT NULL,
    CONSTRAINT [PK_MailGroupMailAddressesXtab_1] PRIMARY KEY CLUSTERED ([ID] ASC)) ON [PRIMARY]
END
