

if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MarcheProdotti]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)

/****** Object:  Table [dbo].[MarcheProdotti]    Script Date: 24/04/2018 09:22:10 ******/
BEGIN

/****** Object:  Table [dbo].[MarcheProdotti]    Script Date: 24/04/2018 12:45:36 ******/
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON

CREATE TABLE [dbo].[MarcheProdotti](
	[IDMarca] [smallint] NOT NULL,
	[DescMarca] [varchar](100) NOT NULL CONSTRAINT [DF_MarcheProdotti_Descrizione]  DEFAULT (''),
	[IDMarcaOligest] [smallint] NOT NULL CONSTRAINT [DF_MarcheProdotti_IDMarcaOligest]  DEFAULT ((0)),
 CONSTRAINT [PK_MarcheProdotti] PRIMARY KEY CLUSTERED 
(
	[IDMarca] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_PADDING OFF

END

BEGIN
   IF NOT EXISTS (SELECT * FROM Contatori 
                   WHERE Nome = 'IDMARCA')
   BEGIN
       INSERT INTO Contatori (Nome, Valore)
       VALUES ('IDMARCA', 0)
   END
END

