IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'GruppoWeb')
BEGIN
CREATE TABLE [GruppoWeb](
	[Gruppo] [nvarchar](20) NOT NULL,
	[Cliente] [nvarchar](20) NOT NULL,
	[Descrizione] [nvarchar](50) NULL,
	[Sequenza] [int] NULL,
 CONSTRAINT [PK_GruppoWeb] PRIMARY KEY CLUSTERED 
(
	[Gruppo] ASC,
	[Cliente] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
ALTER TABLE [dbo].[GruppoWeb] ADD  CONSTRAINT [DF_GruppoWeb_Sequenza]  DEFAULT ((0)) FOR [Sequenza]
END
GO

IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'GruppoWebMarchio')
BEGIN
CREATE TABLE [GruppoWebMarchio](
	[Gruppo] [nvarchar](20) NOT NULL,
	[Cliente] [nvarchar](20) NOT NULL,
	[Marchio] [nvarchar](5) NOT NULL,
 CONSTRAINT [PK_GruppoWebMarchio] PRIMARY KEY CLUSTERED 
(
	[Gruppo] ASC,
	[Cliente] ASC,
	[Marchio] 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
GO

IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'GruppoWebNegozio')
BEGIN
CREATE TABLE [GruppoWebNegozio](
	[Gruppo] [nvarchar](20) NOT NULL,
	[Cliente] [nvarchar](20) NOT NULL,
	[Negozio] [nvarchar](10) NOT NULL,
	[Sequenza] [int] NOT NULL,
 CONSTRAINT [PK_GruppiNegozi] PRIMARY KEY CLUSTERED 
(
	[Gruppo] ASC,
	[Cliente] ASC,
	[Negozio] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
ALTER TABLE [GruppoWebNegozio] ADD  CONSTRAINT [DF_GruppoWebNegozi_Sequenza]  DEFAULT ((0)) FOR [Sequenza]
END
GO


IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Negozio' AND COLUMN_NAME = 'ExportWeb')
BEGIN
ALTER TABLE Negozio ADD	ExportWeb int NULL
ALTER TABLE [Negozio] ADD  CONSTRAINT [DF_Negozio_ExportWeb]  DEFAULT ((0)) FOR [ExportWeb]
END
GO



