SQL 2005 Management Studio throwing syntax errors while trying to save changes to a table in Design view
Just recently, SQL 2005 Management Studio started throwing syntax errors while trying to save changes to tables. These are tables being made in Design view, not as TSQL scripts.
'Build_Group' table
- Unable to create index 'PK_Build_Group'.
Incorrect syntax near ','.
Based on the error, it seems that the recreation of the clustered index on the primary key is failing, but this is an entirely automated process by SQL, its own generated TSQL behind the scenes, and the change to the table was not to the key field, ie the clustered index that generated just fine before is now failing.
This install of SQL is more than a year old and I work in it eve开发者_StackOverflow中文版ry day with no problem. Nothing has changed to the environment that I know of.
Anyone seen this before ?
== EDIT TO ORIGINAL ==============================
Below is the Generated Change Script
BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.Build_Group ADD CONSTRAINT
PK_Build_Group PRIMARY KEY CLUSTERED
(
build_group_pk
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
COMMIT
The syntax error is occurring on the WITH line. If I rem out the two ALLOW options, it will run.
here is my suggestion:
1) reboot your PC
2) enter SSMS
3) right click the table and select "refresh"
4) open the table, right click and select "Design", and make a change
5) click on the "generate change script" toolbar icon (or from the menu - "Table Designer" then "generate change script")
6) store a copy of this change script
7) attempt to save the table
8) if you still get an error, edit your question to include the change script
I have the same problem using SSMS v10 (SQL 2008) against an SQL Server 2000 server/database. If I create a table with a few columns in the designer and also set a primary key using the designer, then save and try Script table as > Create to > New query window it generates SQL with incorrect syntax.
Msg 170, Level 15, State 1, Line 58
Line 58: Incorrect syntax near '('.
Deleting the two ALLOW options didn't work for me, but removing the entire WITH clause does fix the issue. Regardless of whether this is the right thing to do, why does SMSS generate bad scripts?
精彩评论