5

I get the following error from the SQL Script I am trying to run:

Msg 102, Level 15, State 1, Line 10 Incorrect syntax near ','.

This is the SQL script:

IF NOT EXISTS (SELECT * 
                 FROM dbo.sysobjects 
                WHERE id = OBJECT_ID(N'[dbo].HDDB_DataSource]') 
                  AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[HDDB_DataSource](
 [ID] [int] IDENTITY(1,1) NOT NULL,
 [Name] [nvarchar](255) NOT NULL,
 [Type] [nvarchar](50) NOT NULL,
 [XmlFileName] [nvarchar](255) NULL,
 [ConnectionString] [nvarchar](255) NULL),
 CONSTRAINT [PK_DataSource] PRIMARY KEY CLUSTERED 
(
 [ID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END

I am using SQL Server 2005.

7 Answers 7

8

Remove the ")" in "[ConnectionString] nvarchar NULL),"

Sign up to request clarification or add additional context in comments.

1 Comment

+1 you can paste the OP's code into SSMS and click on the "parse" check icon on the toolbar and get the error message. If you remove the ")" as described in this answer, and repeat the "parse" (or actually run it and create the table) the error goes away and the code runs.
3

Get rid of the close paren at the end of the ConnectionString column line before the comma and it should work

Comments

3

Do you see the extraneous ) at the end of this line?

 [ConnectionString] [nvarchar](255) NULL),

Comments

2

You appear to have duplicate lines here:

) ON [PRIMARY]
) ON [PRIMARY]

so the braces are not balanced.

1 Comment

They're not duplicates nor a syntax error. First one is filegroup for the primary key and second is the filegroup for the table.
2

Remove ), after the last field (before the constraint).

Comments

1

Duplicates

) ON [PRIMARY]
) ON [PRIMARY]

1 Comment

They're not duplicates nor a syntax error. First one is filegroup for the primary key and second is the filegroup for the table.
0

Remove , from last row [ConnectionString] nvarchar NULL),

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.