July 4, 2009 at 1:10 pm
[font="Arial"]Hi all!
I'm trying to copy structure of my tables to another server.I generated the script as below.
as I run it on the target server I encounter this error:
Server: Msg 170, Level 15, State 1, Line 10
Line 10: Incorrect syntax near '('.
I changes CREATE to ALTER and run it on the source server but I recieved the same error
whats wrong with it? I didn't write even a single letter manually!
Please Help![/font]
USE [mydb]
GO
/****** Object: Table [dbo].[DailyPrice] Script Date: 07/04/2009 21:22:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[DailyPrice](
[DailyPriceID] [int] IDENTITY(1,1) NOT NULL,
[Date] [datetime] NOT NULL,
[MaterialID] [smallint] NOT NULL,
[UnitID] [smallint] NOT NULL,
[Price] [money] NOT NULL,
CONSTRAINT [PK_DailyPrice] PRIMARY KEY CLUSTERED
(
[DailyPriceID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO
USE [mydb]
GO
ALTER TABLE [dbo].[DailyPrice] WITH CHECK ADD CONSTRAINT [FK_DailyPrice_Material] FOREIGN KEY([MaterialID])
REFERENCES [dbo].[Material] ([MaterialID])
GO
ALTER TABLE [dbo].[DailyPrice] WITH CHECK ADD CONSTRAINT [FK_DailyPrice_Unit] FOREIGN KEY([UnitID])
REFERENCES [dbo].[Unit] ([UnitID])
July 4, 2009 at 2:00 pm
Are both servers running the same version of SQL?
What version are they running? This looks like a SQL 2000 script.
The create table runs without error on my SQL 2008 server.
Changing create to alter will give you errors, the structure of an ALTER TABLE statement is very different from a CREATE TABLE. It's not like creating/altering procedures, views or functions.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
July 4, 2009 at 8:10 pm
Hi GilaMonster! Thank you very much indeed.
No they are different.The source is SQL Server2005 and destination is SQL Server 2000 and that was the point.
I removed WITH (IGNORE_DUP_KEY = OFF) and i was OK. thank you again.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply