SQL Server 2012生成的脚本无法再次运行?

时间:2016-03-03 08:45:30

标签: sql sql-server sql-server-2012 generate-scripts

从数据库生成脚本时遇到问题。这很简单,但我不知道如何解决它。 存储过程对象在Table对象之前创建。这是所有脚本:

 USE [ComicSellerManagement]
GO
/****** Object:  StoredProcedure [dbo].[sp_AddingComicGenre]    Script Date: 3/3/2016 3:39:38 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create proc [dbo].[sp_AddingComicGenre]
@name nvarchar(50),
@info nvarchar(max)
as begin
    insert into COMIC_GENRE values (@name, @info)
end
GO
/****** Object:  StoredProcedure [dbo].[sp_DeletingComicGenre]    Script Date: 3/3/2016 3:39:38 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create proc [dbo].[sp_DeletingComicGenre]
@id int
as begin
    delete from COMIC_GENRE where ID = @id
end
GO
/****** Object:  StoredProcedure [dbo].[sp_LoadingComicGenre]    Script Date: 3/3/2016 3:39:38 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create proc [dbo].[sp_LoadingComicGenre]
as begin
    select * from COMIC_GENRE
end
GO
/****** Object:  StoredProcedure [dbo].[sp_UpdatingComicGenre]    Script Date: 3/3/2016 3:39:38 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create proc [dbo].[sp_UpdatingComicGenre]
@id int,
@name nvarchar(50),
@info nvarchar(max)
as begin
    update COMIC_GENRE
    set GenreName = @name, Info = @info
    where ID = @id
end
GO
/****** Object:  Table [dbo].[COMIC]    Script Date: 3/3/2016 3:39:38 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[COMIC](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar](50) NULL,
    [Genre] [int] NULL,
    [PublishYear] [int] NULL,
    [Publisher] [int] NULL,
    [Actor] [nvarchar](50) NULL,
    [Price] [money] NULL,
 CONSTRAINT [PK_COMIC] PRIMARY KEY CLUSTERED 
(
    [ID] 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
/****** Object:  Table [dbo].[COMIC_GENRE]    Script Date: 3/3/2016 3:39:38 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[COMIC_GENRE](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [GenreName] [nvarchar](50) NULL,
    [Info] [nvarchar](255) NULL,
 CONSTRAINT [PK_COMIC_GENRE] PRIMARY KEY CLUSTERED 
(
    [ID] 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
/****** Object:  Table [dbo].[COMIC_PUBLISHER]    Script Date: 3/3/2016 3:39:38 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[COMIC_PUBLISHER](
    [ID] [int] IDENTITY(1,1) NOT NULL,
    [PublisherName] [nvarchar](50) NULL,
    [Adress] [nvarchar](max) NULL,
    [PhoneContact] [char](11) NULL,
    [Discount] [float] NULL,
 CONSTRAINT [PK_COMIC_PUBLISHER] PRIMARY KEY CLUSTERED 
(
    [ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[COMIC_PUBLISHER] ADD  CONSTRAINT [DF_COMIC_PUBLISHER_Discount]  DEFAULT ((0)) FOR [Discount]
GO
ALTER TABLE [dbo].[COMIC]  WITH CHECK ADD  CONSTRAINT [FK_COMIC_COMIC_GENRE] FOREIGN KEY([Genre])
REFERENCES [dbo].[COMIC_GENRE] ([ID])
GO
ALTER TABLE [dbo].[COMIC] CHECK CONSTRAINT [FK_COMIC_COMIC_GENRE]
GO
ALTER TABLE [dbo].[COMIC]  WITH CHECK ADD  CONSTRAINT [FK_COMIC_COMIC_PUBLISHER] FOREIGN KEY([Publisher])
REFERENCES [dbo].[COMIC_PUBLISHER] ([ID])
GO
ALTER TABLE [dbo].[COMIC] CHECK CONSTRAINT [FK_COMIC_COMIC_PUBLISHER]
GO

我无法运行此sql文件来恢复任何计算机中的数据库。有什么建议让我解决这个问题吗?

1 个答案:

答案 0 :(得分:2)

  1. 在生成脚本时尝试更改此选项 -
  2. enter image description here

    1. 另一种解决方案是尝试使用dbForge架构比较

    2. 使用备份&#39>