此脚本是从 SQL Server Management Studio 生成的。为什么会出现此错误,如何修复 ALTER 脚本?请注意,我将“CREATE”一词更改为“ALTER”。所以我猜测 CREATE 语法与 ALTER 语法略有不同,或者限制较少。我正在使用 SQL Server 2008 Express。我看到它告诉我以分号结尾,但我想确保终止该语句不会在以后给我带来任何问题。如果您可以描述每条查询的功能以及我们正在更改的内容,则可以获得奖励积分。
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--CREATE TABLE [dbo].[defect](
ALTER TABLE [dbo].[defect](
[defect_id] [bigint] IDENTITY(1,1) NOT NULL,
[defect_number] [nvarchar](50) NULL,
[defect_type] [nvarchar](50) NULL,
[date_created] [datetime] NULL,
[user_identified_by] [nvarchar](50) NULL,
[status] [nvarchar](50) NULL,
[date_modified] [datetime] NULL,
[user_qa] [nvarchar](50) NULL,
[severity] [nvarchar](50) NULL,
[environment] [nvarchar](50) NULL,
[user_assigned] [nvarchar](50) NULL,
[project] [nvarchar](50) NULL,
[target_table_affected] [nvarchar](50) NULL,
[required_for_go_live] [nvarchar](50) NULL,
[project_phase] [nvarchar](50) NULL,
[completion_hours] [nvarchar](50) NULL,
[date_migrate_prod] [datetime] NULL,
[description] [text] NULL,
[table_columns_affected] [text] NULL,
[sample_data] [text] NULL,
[action_taken] [text] NULL,
[supp_detail_links] [text] NULL,
[supp_detail_links_dtml] [text] NULL,
[thread] [bigint] NULL,
CONSTRAINT [PK_defect] PRIMARY KEY CLUSTERED
(
[defect_id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
错误:
Msg 102, Level 15, State 1, Line 1
'(' 附近的语法不正确
。Msg 319, Level 15, State 1, Line 29
关键字'with'附近的语法不正确。如果此语句是公共表表达式,则为 xmlnamespaces 子句或更改跟踪上下文子句,前面的语句必须以分号结束。