views:

115

answers:

1

When using the 'Script Index as CREATE To' to duplicate an index from one table to another table I am not able to run the script. Without editing the generated code I get an error. I get the same error when working with any 'Script XXX as CREATE To' generated code. Any comments/suggestions to solve this problem?

ERROR:

Msg 170, Level 15, State 1, Line 6 Line 6: Incorrect syntax near '('.

SCRIPT:

CREATE NONCLUSTERED INDEX [IX_IncidentStop_Note] ON [dbo].[IncidentStop_Note] 
(
    [IncidentStopID] ASC,
    [NoteID] ASC,
    [Active_Fl] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

EDIT:

As from the answer from Stuart Ainsworth it turns out I am in SQL Server 2000 (80) Compatibility level. My question would slightly change to how can I duplicate something from one table to another while working in 2005 but having the compatibility level of 2000?

+2  A: 

What's the compatibility mode or server level set to for the destination database? Is it SQL 2000 (or compatibility mode 80)? If so, then the WITH option will not run; the syntax generated by the SQL 2005 Mgmt Studio is 2005 compliant (even if you issue it against a SQL 2000 server or 2000-compliant database).

Stuart Ainsworth
It is set to SQL Server 2000 (80). Is there a way to accomplish what I am trying to do with it being 2000?
stewsha
You can set the default scripting options to be SQL 2000 compliant (under tools.. Scripting... Script for Server Version), but Mgmt Studio doen't allow you to script-for-version-on-the-fly.
Stuart Ainsworth
THANKS A BUNCH! I've had this problem for a while now and decided finally to ask the internet.
stewsha