20 messaggi dal 06 settembre 2002
Ciao a tutti, ho uno script di creazione di alcune tabelle.
Quando lomando in esecuzione all'interno del database mi ritornano degli errori.

Lo script è questo:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[logExport]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[logExport](
[logExportID] [smallint] IDENTITY(1,1) NOT NULL,
[logExportFileName] [varchar](50) NOT NULL,
[logExportOpCode] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ImportFields]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ImportFields](
[ImportFieldsID] [smallint] IDENTITY(1,1) NOT NULL,
[ImportFieldsName] [varchar](50) NOT NULL,
CONSTRAINT [PK_ImportFields] PRIMARY KEY CLUSTERED
(
[ImportFieldsID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FMSData]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[FMSData](
[FMSDataID] [int] IDENTITY(1,1) NOT NULL,
[FMSDataRANumber] [varchar](50) NULL,
[FMSDataCheckOutStationCode] [varchar](50) NULL,
[FMSDataCheckOutDate] [int] NULL,
[FMSDataCheckOutTime] [int] NULL,
[FMSDataCheckInStationCode] [varchar](50) NULL,
[FMSDataCheckInDate] [int] NULL,
[FMSDataCheckInTime] [int] NULL,
[FMSDataRemarks] [varchar](50) NULL,
[FMSDataCustomerName] [varchar](50) NULL,
[FMSDataCustomerAddress] [varchar](max) NULL,
[FMSDataCustomerDriveLicense] [varchar](50) NULL,
[FMSDataCustomerBirthdate] [int] NULL,
[FMSDataMVANumber] [varchar](50) NULL,
[FMSDataPlateNumber] [varchar](50) NULL,
[FMSDataCustomerBirthPlace] [varchar](50) NULL,
[FMSDataLocalContact] [varchar](50) NULL,
[FMSDataCustomerCF_PIVA] [varchar](50) NULL,
[FMSDataCustomerAppliedPrice] [varchar](50) NULL,
[FMSDataMiscellanousCode] [varchar](50) NULL,
[FMSDataAWDNumber] [varchar](50) NULL,
[FMSDataAlternativeAWDNumber] [varchar](50) NULL,
[FMSDataPAIAmount] [int] NULL,
[FMSDataCDWAmount] [int] NULL,
[FMSDataBillingCompany] [varchar](50) NULL,
[FMSDataBillingName] [varchar](50) NULL,
[FMSDataBillingAddress] [varchar](max) NULL,
[FMSDataCreditClubCode] [varchar](50) NULL,
[FMSDataCreditCardNumber] [varchar](50) NULL,
[FMSDataCustomerVATNumber] [varchar](50) NULL,
CONSTRAINT [PK_FMSData] PRIMARY KEY CLUSTERED
(
[FMSDataID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[formatFields]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[formatFields](
[formatFieldsID] [int] IDENTITY(1,1) NOT NULL,
[formatFieldsDescription] [varchar](50) NOT NULL,
CONSTRAINT [PK_formatFields] PRIMARY KEY CLUSTERED
(
[formatFieldsID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[logImport]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[logImport](
[logImportID] [smallint] IDENTITY(1,1) NOT NULL,
[logImportFileName] [varchar](50) NOT NULL,
[logImportDateTime] [smalldatetime] NOT NULL,
[logImportFMS] [bit] NOT NULL,
[logImportExported] [bit] NOT NULL,
[logImportOpCode] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DistrictData]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[DistrictData](
[DistrictDataID] [int] IDENTITY(1,1) NOT NULL,
[DistrictDataDistrict] [varchar](50) NULL,
[DistrictDataTicketNumber] [varchar](50) NULL,
[DistrictDataTicketDate] [datetime] NULL,
[DistrictDataTicketTime] [datetime] NULL,
[DistrictDataPlateNumber] [varchar](50) NULL,
[DistrictDataVehicleType] [varchar](10) NULL,
CONSTRAINT [PK_DistrictData] PRIMARY KEY CLUSTERED
(
[DistrictDataID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[formatMaster]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[formatMaster](
[formatMasterID] [smallint] IDENTITY(1,1) NOT NULL,
[formatMasterDescription] [varchar](50) NOT NULL,
[formatMasterType] [char](3) NOT NULL,
CONSTRAINT [PK_formatMaster] PRIMARY KEY CLUSTERED
(
[formatMasterID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[formatDetail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[formatDetail](
[formatDetailID] [smallint] IDENTITY(1,1) NOT NULL,
[formatMasterID] [smallint] NOT NULL,
[formatDetailFieldID] [int] NOT NULL,
[formatDetailFieldNumber] [smallint] NOT NULL,
[formatDetailStartPosition] [smallint] NULL,
[formatDetailFieldLenght] [smallint] NULL,
[formatDetailDelimiter] [char](1) NULL,
CONSTRAINT [PK_formatDetail] PRIMARY KEY CLUSTERED
(
[formatDetailID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_formatDetail_formatMaster]') AND parent_object_id = OBJECT_ID(N'[dbo].[formatDetail]'))
ALTER TABLE [dbo].[formatDetail] WITH CHECK ADD CONSTRAINT [FK_formatDetail_formatMaster] FOREIGN KEY([formatMasterID])
REFERENCES [dbo].[formatMaster] ([formatMasterID])

Gli errori:
Server: Msg 170, Level 15, State 1, Line 9
Line 9: Incorrect syntax near '('.
Server: Msg 170, Level 15, State 1, Line 14
Line 14: Incorrect syntax near 'max'.
Server: Msg 170, Level 15, State 1, Line 9
Line 9: Incorrect syntax near '('.
Server: Msg 170, Level 15, State 1, Line 14
Line 14: Incorrect syntax near '('.
Server: Msg 170, Level 15, State 1, Line 10
Line 10: Incorrect syntax near '('.
Server: Msg 170, Level 15, State 1, Line 14
Line 14: Incorrect syntax near '('.

Grazie in anticipo.
1.024 messaggi dal 19 dicembre 2003
Contributi | Blog
Lo esegui in SQL Server 2000 o in SQL Server 2005?
I nomi degli oggetti di sistema (sys.objects, sys.foreign_keys, ecc) sono quelli di SQL Server 2005. Al di la di questo lo script è corretto...

Bye

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.