使用SSMS中生成的主键脚本的语法错误

时间:2013-01-15 20:14:03

标签: sql sql-server sql-server-2000

我正在尝试将主键从一个数据库(SQL Server 2000)移动到另一个数据库。在原始数据库中,我有一个主键,我使用SSMS将其编写到新的查询窗口:

USE [DatabaseName_Test]
GO

ALTER TABLE [dbo].[tbl_itinerary_item] ADD  CONSTRAINT [PK_tbl_itinerary_item] PRIMARY KEY CLUSTERED 
(
    [activity_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO

我所做的就是更改数据库:

USE [DatabaseName]
GO

ALTER TABLE [dbo].[tbl_itinerary_item] ADD  CONSTRAINT [PK_tbl_itinerary_item] PRIMARY KEY CLUSTERED 
(
    [activity_id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO

我得到的错误是

  

Msg 170,Level 15,State 1,Line 5 Line 5:
  '('。

附近的语法不正确

我错过了什么?

1 个答案:

答案 0 :(得分:1)

尝试像这样简化你的SQL:

ALTER TABLE [dbo].[tbl_itinerary_item] ADD  CONSTRAINT [PK_tbl_itinerary_item] PRIMARY KEY 
(
    [activity_id] ASC
)ON [PRIMARY]
GO