Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5651
  • Last Modified:

Msg 170, Level 15, State 1, Line 4 Incorrect syntax near max on CREATE in SQLCMD

Hi everyone, i am trying to run the CREATE proceedure on SQLCMD and i have come accross a snagg.

The code is below.
-------
USE [MyDB]
GO
/****** Object:  Table [dbo].[MyTable]    Script Date: 11/29/2007 13:25:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MyTable](
      [Column1] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
      [Column2] [int] IDENTITY(1,1) NOT NULL,
      [Column3] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
---------

It all is working apart from when i get to
[Column3] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

Anywhere i use[nvarchar](max) it keeps coming up with the above error, regardless of what table i am trying to crate.

Any help would be very much appriated.
Thank you

Baker
0
Bakersville
Asked:
Bakersville
  • 4
  • 3
1 Solution
 
MikeTooleCommented:
Remove the [] from around the data types (also you don't need them round simple column names):

E.g.
  Column3 nvarchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
is your target database eventually in compatibility mode 80 (means sql 2000)?
if yes, change it to 90 (sql 2005), and your code should run fine.
0
 
MikeTooleCommented:
Ignore my previous post, your create statement worked for me as is.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
 
MikeTooleCommented:
angelIII,
I tried a switch to compatibility = 80 and it still worked.
Now I'm puzzled.
Mike
0
 
BakersvilleAuthor Commented:
Thank you both for your help.

I changed the compatibility to 90 and it works great.

Thanks for your quick responses, means i can get the site live tonight now.

Baker
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>angelIII,
>I tried a switch to compatibility = 80 and it still worked.
>Now I'm puzzled.
>Mike
well, you might have take the wrong database/server ....
0
 
MikeTooleCommented:
angelIII,
<well, you might have take the wrong database/server .... >
No, I checked that out. It complained about the COLLATE when I rolled compatibility back to 70, but let the (Max) through.
But at least the problem got fixed :-)
Mike
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now