views:

86

answers:

2

I scripted the tables in my dev database using SQL 2008 - generate scripts option (Datbase->right click->Tasks->Generate Scripts) and ran it on the staging database, but the script throws the below error for each table

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

Below is the script for one of my table

ALTER TABLE [dbo].[Customer](
    [CustomerID] [int] IDENTITY(1,1) NOT NULL,
    [FirstName] [nvarchar](500) NULL,
    [LastName] [nvarchar](500) NULL,
    [DateOfBirth] [datetime] NULL,
    [EmailID] [nvarchar](200) NULL,
    [ContactForOffers] [bit] NULL,
 CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED 
(
    [CustomerID] 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

Any help will be much appreciated.

+1  A: 

The script you gave is 100% correct if it was a CREATE TABLE

As an ALTER TABLE, it's completely wrong: this is why you get the error...

The script has been changed since generation: SSMS does not give me "script as ALTER" option

gbn
+1  A: 

If you are trying to script a create, and then run it in a new database, wouldn't you want the 'CREATE' instead of ALTER? I also do not have a script as 'alter' option in SSMS, so as gbn says, it must have been changed.

Edit: As a side note - do you really want field lengths of 500 for first and last name? Seems excessive.

EJB