jeffreyshek
jeffreyshek

Reputation: 63

Incorrect syntax near ','

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.

Upvotes: 5

Views: 36944

Answers (7)

mjv
mjv

Reputation: 75095

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

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

Upvotes: 3

Nakul Chaudhary
Nakul Chaudhary

Reputation: 26144

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

Upvotes: 0

Guffa
Guffa

Reputation: 700192

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

Upvotes: 2

Gabe
Gabe

Reputation: 50483

Duplicates

) ON [PRIMARY]
) ON [PRIMARY]

Upvotes: 1

Rob Packwood
Rob Packwood

Reputation: 3798

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

Upvotes: 3

user253984
user253984

Reputation:

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

Upvotes: 8

Rob Osborne
Rob Osborne

Reputation: 4997

You appear to have duplicate lines here:

) ON [PRIMARY]
) ON [PRIMARY]

so the braces are not balanced.

Upvotes: 2

Related Questions