我在使用 SQL Server 2012 的客户站点上安装时发生错误。我能够在 SQLExpress 2012 上本地重现语法错误。相同的 DDL 脚本在 2008 R2 下运行良好,但由于“'44445'附近的语法不正确”而失败。
检查正在执行的 SQL,文本“44445”被注释掉。同样,此 SQL 适用于 2008 R2。发布的最后一行是语法违规者。请注意,与本示例的大部分内容一样,它已被注释掉。
[snipped]
IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'Updatable' , N'USER',N'dbo', N'TABLE',N'PublishLog', NULL,NULL))
EXEC dbo.sp_addextendedproperty @name=N'Updatable', @value=N'True' , @level0type=N'USER',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PublishLog'
GO
--SET ANSI_NULLS ON
--GO
--SET QUOTED_IDENTIFIER ON
--GO
--IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[MetaData]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
--BEGIN
--CREATE TABLE [dbo].[MetaData](
-- [ID] [int] IDENTITY(1,1) NOT NULL,
-- [DataName] [nvarchar](255) NULL,
-- [DataDescription] [nvarchar](255) NULL,
-- CONSTRAINT [MetaData_PK] PRIMARY KEY NONCLUSTERED
--(
-- [ID] ASC
--) ON [PRIMARY]
--) ON [PRIMARY]
--END
--GO
--SET ANSI_NULLS ON
--GO
--SET QUOTED_IDENTIFIER OFF
--GO
--IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[T_MetaData_DTrig]') AND OBJECTPROPERTY(id, N'IsTrigger') = 1)
--EXEC dbo.sp_executesql @statement = N'CREATE TRIGGER [dbo].[T_MetaData_DTrig] ON [dbo].[MetaData] FOR DELETE AS
--SET NOCOUNT ON
--/* * PREVENT DELETES IF DEPENDENT RECORDS IN ''DocumentsData'' */
--IF (SELECT COUNT(*) FROM deleted, DocumentsData WHERE (deleted.ID = DocumentsData.MetaTagsID)) > 0
-- BEGIN
-- RAISERROR 44445 ''The record can''''t be deleted or changed. Since related records exist in table ''''DocumentsData'''', referential integrity rules would be violated.''
-- ROLLBACK TRANSACTION
-- END
[snipped]