Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Table create error - I am stumped

Author  Topic 

duanecwilson
Constraint Violating Yak Guru

273 Posts

Posted - 2009-06-05 : 12:07:33
This one works fine (in fact it was a generated script from an existing table):
CREATE TABLE [dbo].[ModelLU](
[ModelID] [int] IDENTITY(1,1) NOT NULL,
[Model] [nvarchar](255) NULL,
CONSTRAINT [aaaaaModelLU_PK] PRIMARY KEY NONCLUSTERED
(
[ModelID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

This one comes with the error below:
CREATE TABLE [dbo].[v2_Office] (
[OfficeID] [int] IDENTITY(1,1) NOT NULL,
[OfficeName] [nvarchar](15) NULL,
[Office] [nvarchar](4) NULL,
[Notes] [nvarchar](50) NULL),
CONSTRAINT [aaaaaaOffice_PK] PRIMARY KEY NONCLUSTERED
(
[OfficeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

quote:
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near ','.
Msg 319, Level 15, State 1, Line 9
Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.


What on earth is the difference here?

Duane

duanecwilson
Constraint Violating Yak Guru

273 Posts

Posted - 2009-06-05 : 12:13:15
I found the error after posting. I even had these 2 comparing in Notepad. I don't know why I didn't get it sooner.

Duane
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2009-06-05 : 12:23:55
Remove bracket after notes column declaration. Just try the below

CREATE TABLE [dbo].[v2_Office] (
[OfficeID] [int] IDENTITY(1,1) NOT NULL,
[OfficeName] [nvarchar](15) NULL,
[Office] [nvarchar](4) NULL,
[Notes] [nvarchar](50) NULL,
CONSTRAINT [aaaaaaOffice_PK] PRIMARY KEY NONCLUSTERED
(
[OfficeID] 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 to Top of Page
   

- Advertisement -