Search code examples
sqlsql-serversql-server-2000

Incorrect sytax near '(' in SQL server


I've got following error:

Msg 170, Level 15, State 1, Line 9 Line 9:
Incorrect syntax near '('.

My SQL is:

USE [dbname]
GO

/****** Object:  Table [dbo].[table_name]    Script Date: 10/20/2014 16:41:41 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[table_name]
(
    [ID] [int] NOT NULL,
    [sth] [nvarchar](200) NULL,
    [list] [smallint] NULL,

    CONSTRAINT [PK_table_name] 
       PRIMARY KEY CLUSTERED ([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]
GO

Unfortunately I can't see any error. Moreover the script is generated by SQL Server Management Studio (click on table -> script table as -> create to -> new query window) because I want to make very table to another.

Is there something wrong in the query or maybe can it be caused by insufficient privileges (I'm not logged as the database owner or system administrator anyway I can create new table by clicking "new table" on the tables directory).

EDIT:

I'm using SQL Server Management Studio 2008 R2 and the server is Microsoft SQL Server 2000 - 8.00.2187.

EDIT2:

I was trying to execute a script generated by the MS SQL Server Management Studio 2008 R2 on the SQL Server 2000. As far as I understand.


Solution

  • Try

    CREATE TABLE table_name
    (
        ID int NOT NULL,
        sth nvarchar(200) NULL,
        list smallint NULL,
    
        CONSTRAINT PK_table_name PRIMARY KEY (ID)
    ) 
    

    This omits all particular syntax and the special WITH options (that have all been given defaults anyway). This syntax is accepted by all versions and editions of SQL Server I'm familiar with. If this works, your problem is a version mismatch. If this doesn't work, your problem is probably of an entirely different nature altogether.