C# を使用して、空のデータベースのテーブルを SQL ファイルから復元しようとしています。
これはコードです:
namespace KezberProjectManager
{
public partial class VisitClear : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string sqlConnectionString = "Data Source=JOSH-PC\\SQLEXPRESS;Initial Catalog=KezBlu;Integrated Security=True;MultipleActiveResultSets=True";
FileInfo file = new FileInfo(Path.Combine(
HostingEnvironment.ApplicationPhysicalPath,
@"App_Data\kb.sql"));
string script = file.OpenText().ReadToEnd();
SqlConnection conn = new SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);
}
}
}
スクリプトは次のとおりです。
USE [KezBlu]
GO
/****** Object: ForeignKey [Customer_Case] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Cases] DROP CONSTRAINT [Customer_Case]
GO
/****** Object: ForeignKey [Schedule_Case] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Cases] DROP CONSTRAINT [Schedule_Case]
GO
/****** Object: ForeignKey [Status_Case] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Cases] DROP CONSTRAINT [Status_Case]
GO
/****** Object: ForeignKey [Group_Employee] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Employee] DROP CONSTRAINT [Group_Employee]
GO
/****** Object: ForeignKey [Employee_EmployeGroupFilter] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[EmployeGroupFilters] DROP CONSTRAINT [Employee_EmployeGroupFilter]
GO
/****** Object: ForeignKey [Group_EmployeGroupFilter] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[EmployeGroupFilters] DROP CONSTRAINT [Group_EmployeGroupFilter]
GO
/****** Object: ForeignKey [Employee_LockedDate] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[LockedDates] DROP CONSTRAINT [Employee_LockedDate]
GO
/****** Object: ForeignKey [Schedule_Project] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Project] DROP CONSTRAINT [Schedule_Project]
GO
/****** Object: ForeignKey [Employee_Schedule] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Schedule] DROP CONSTRAINT [Employee_Schedule]
GO
/****** Object: ForeignKey [Recurring_Schedule] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Schedule] DROP CONSTRAINT [Recurring_Schedule]
GO
/****** Object: ForeignKey [Project_Task] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Task] DROP CONSTRAINT [Project_Task]
GO
/****** Object: ForeignKey [Schedule_Task] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Task] DROP CONSTRAINT [Schedule_Task]
GO
/****** Object: ForeignKey [Schedule_Task1] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Task] DROP CONSTRAINT [Schedule_Task1]
GO
/****** Object: Table [dbo].[Task] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Task] DROP CONSTRAINT [Project_Task]
GO
ALTER TABLE [dbo].[Task] DROP CONSTRAINT [Schedule_Task]
GO
ALTER TABLE [dbo].[Task] DROP CONSTRAINT [Schedule_Task1]
GO
DROP TABLE [dbo].[Task]
GO
/****** Object: Table [dbo].[Cases] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Cases] DROP CONSTRAINT [Customer_Case]
GO
ALTER TABLE [dbo].[Cases] DROP CONSTRAINT [Schedule_Case]
GO
ALTER TABLE [dbo].[Cases] DROP CONSTRAINT [Status_Case]
GO
DROP TABLE [dbo].[Cases]
GO
/****** Object: Table [dbo].[Project] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Project] DROP CONSTRAINT [Schedule_Project]
GO
DROP TABLE [dbo].[Project]
GO
/****** Object: Table [dbo].[EmployeGroupFilters] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[EmployeGroupFilters] DROP CONSTRAINT [Employee_EmployeGroupFilter]
GO
ALTER TABLE [dbo].[EmployeGroupFilters] DROP CONSTRAINT [Group_EmployeGroupFilter]
GO
DROP TABLE [dbo].[EmployeGroupFilters]
GO
/****** Object: Table [dbo].[LockedDates] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[LockedDates] DROP CONSTRAINT [Employee_LockedDate]
GO
DROP TABLE [dbo].[LockedDates]
GO
/****** Object: Table [dbo].[Schedule] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Schedule] DROP CONSTRAINT [Employee_Schedule]
GO
ALTER TABLE [dbo].[Schedule] DROP CONSTRAINT [Recurring_Schedule]
GO
DROP TABLE [dbo].[Schedule]
GO
/****** Object: Table [dbo].[Employee] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Employee] DROP CONSTRAINT [Group_Employee]
GO
DROP TABLE [dbo].[Employee]
GO
/****** Object: Table [dbo].[Colors] Script Date: 04/24/2013 21:35:08 ******/
DROP TABLE [dbo].[Colors]
GO
/****** Object: Table [dbo].[Customers] Script Date: 04/24/2013 21:35:08 ******/
DROP TABLE [dbo].[Customers]
GO
/****** Object: Table [dbo].[Group] Script Date: 04/24/2013 21:35:08 ******/
DROP TABLE [dbo].[Group]
GO
/****** Object: Table [dbo].[Recurring] Script Date: 04/24/2013 21:35:08 ******/
DROP TABLE [dbo].[Recurring]
GO
/****** Object: Table [dbo].[Settings] Script Date: 04/24/2013 21:35:08 ******/
DROP TABLE [dbo].[Settings]
GO
/****** Object: Table [dbo].[Statuses] Script Date: 04/24/2013 21:35:08 ******/
DROP TABLE [dbo].[Statuses]
GO
/****** Object: Table [dbo].[Statuses] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Statuses](
[StatusID] [int] IDENTITY(1,1) NOT NULL,
[StatusDescription] [varchar](50) NULL,
CONSTRAINT [PK_dbo.Statuses] PRIMARY KEY CLUSTERED
(
[StatusID] 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
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Settings] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Settings](
[SettingID] [int] IDENTITY(1,1) NOT NULL,
[SettingKey] [varchar](50) NOT NULL,
[SettingValue] [text] NOT NULL,
CONSTRAINT [PK_dbo.Settings] PRIMARY KEY CLUSTERED
(
[SettingID] 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
/****** Object: Table [dbo].[Recurring] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Recurring](
[RecurringID] [int] IDENTITY(1,1) NOT NULL,
[Period] [int] NULL,
[DateStart] [datetime] NULL,
[DateLast] [datetime] NULL,
[Advance] [int] NULL,
CONSTRAINT [PK_dbo.Recurring] PRIMARY KEY CLUSTERED
(
[RecurringID] 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].[Group] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Group](
[GroupID] [int] IDENTITY(1,1) NOT NULL,
[GroupDescription] [varchar](max) NOT NULL,
[IsReadOnly] [bit] NULL,
CONSTRAINT [PK_dbo.[Group]]] PRIMARY KEY CLUSTERED
(
[GroupID] 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
/****** Object: Table [dbo].[Customers] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Customers](
[CustomerID] [int] IDENTITY(1,1) NOT NULL,
[CustomerDescription] [varchar](max) NULL,
CONSTRAINT [PK_dbo.Customers] 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] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Colors] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Colors](
[ColorID] [int] IDENTITY(1,1) NOT NULL,
[ColorValue] [int] NOT NULL,
CONSTRAINT [PK_dbo.Colors] PRIMARY KEY CLUSTERED
(
[ColorID] 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].[Employee] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Employee](
[EmployeID] [int] IDENTITY(1,1) NOT NULL,
[EmployeName] [varchar](50) NOT NULL,
[EmployeEmail] [varchar](50) NOT NULL,
[EmployePassword] [char](44) NOT NULL,
[DefaultNumWeek] [smallint] NULL,
[GroupID] [int] NULL,
CONSTRAINT [PK_dbo.Employee] PRIMARY KEY CLUSTERED
(
[EmployeID] 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
SET ANSI_PADDING OFF
GO
/****** Object: Table [dbo].[Schedule] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Schedule](
[ScheduleID] [int] IDENTITY(1,1) NOT NULL,
[DateFrom] [datetime] NULL,
[Hours] [decimal](10, 2) NULL,
[EmployeID] [int] NULL,
[RecurringID] [int] NULL,
[Priority] [int] NULL,
[DateTo] [datetime] NULL,
[IsLocked] [bit] NOT NULL,
[BumpPriority] [int] NULL,
CONSTRAINT [PK_dbo.Schedule] PRIMARY KEY CLUSTERED
(
[ScheduleID] 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].[LockedDates] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[LockedDates](
[LockedDateID] [int] IDENTITY(1,1) NOT NULL,
[Date] [datetime] NOT NULL,
[IsYearly] [bit] NOT NULL,
[EmployeeID] [int] NULL,
CONSTRAINT [PK_dbo.LockedDates] PRIMARY KEY CLUSTERED
(
[LockedDateID] 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].[EmployeGroupFilters] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[EmployeGroupFilters](
[EmployeGroupFilterID] [int] IDENTITY(1,1) NOT NULL,
[EmployeID] [int] NOT NULL,
[GroupID] [int] NOT NULL,
CONSTRAINT [PK_dbo.EmployeGroupFilters] PRIMARY KEY CLUSTERED
(
[EmployeGroupFilterID] 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].[Project] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Project](
[ProjectID] [int] IDENTITY(1,1) NOT NULL,
[ProjectTitle] [varchar](max) NOT NULL,
[ProjectDescription] [varchar](max) NOT NULL,
[ScheduleID] [int] NULL,
[EstimatedHours] [decimal](10, 2) NULL,
[IsRetired] [bit] NULL,
[Color] [int] NULL,
[PaymoID] [int] NULL,
CONSTRAINT [PK_dbo.Project] PRIMARY KEY CLUSTERED
(
[ProjectID] 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
/****** Object: Table [dbo].[Cases] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Cases](
[CaseID] [int] IDENTITY(1,1) NOT NULL,
[CaseTitle] [varchar](max) NOT NULL,
[CaseDescription] [varchar](max) NOT NULL,
[CustomerID] [int] NOT NULL,
[ScheduleID] [int] NULL,
[EstimatedHours] [decimal](10, 2) NULL,
[StatusID] [int] NULL,
[Color] [int] NULL,
[CRMID] [varchar](50) NULL,
CONSTRAINT [PK_dbo.Cases] PRIMARY KEY CLUSTERED
(
[CaseID] 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
/****** Object: Table [dbo].[Task] Script Date: 04/24/2013 21:35:08 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Task](
[TaskID] [int] IDENTITY(1,1) NOT NULL,
[TaskTitle] [varchar](max) NOT NULL,
[TaskDescription] [varchar](max) NOT NULL,
[ProjectID] [int] NULL,
[ScheduleID] [int] NULL,
[PaymoID] [int] NULL,
[ParentScheduleID] [int] NULL,
[IsUnscheduelable] [bit] NULL,
[EstimatedHours] [decimal](10, 2) NULL,
[PaymoUser] [varchar](max) NULL,
[PaymoOrder] [int] NULL,
[PaymoEstimateHours] [decimal](10, 2) NULL,
CONSTRAINT [PK_dbo.Task] PRIMARY KEY CLUSTERED
(
[TaskID] 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
/****** Object: ForeignKey [Customer_Case] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Cases] WITH CHECK ADD CONSTRAINT [Customer_Case] FOREIGN KEY([CustomerID])
REFERENCES [dbo].[Customers] ([CustomerID])
GO
ALTER TABLE [dbo].[Cases] CHECK CONSTRAINT [Customer_Case]
GO
/****** Object: ForeignKey [Schedule_Case] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Cases] WITH CHECK ADD CONSTRAINT [Schedule_Case] FOREIGN KEY([ScheduleID])
REFERENCES [dbo].[Schedule] ([ScheduleID])
GO
ALTER TABLE [dbo].[Cases] CHECK CONSTRAINT [Schedule_Case]
GO
/****** Object: ForeignKey [Status_Case] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Cases] WITH CHECK ADD CONSTRAINT [Status_Case] FOREIGN KEY([StatusID])
REFERENCES [dbo].[Statuses] ([StatusID])
GO
ALTER TABLE [dbo].[Cases] CHECK CONSTRAINT [Status_Case]
GO
/****** Object: ForeignKey [Group_Employee] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Employee] WITH CHECK ADD CONSTRAINT [Group_Employee] FOREIGN KEY([GroupID])
REFERENCES [dbo].[Group] ([GroupID])
GO
ALTER TABLE [dbo].[Employee] CHECK CONSTRAINT [Group_Employee]
GO
/****** Object: ForeignKey [Employee_EmployeGroupFilter] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[EmployeGroupFilters] WITH CHECK ADD CONSTRAINT [Employee_EmployeGroupFilter] FOREIGN KEY([EmployeID])
REFERENCES [dbo].[Employee] ([EmployeID])
GO
ALTER TABLE [dbo].[EmployeGroupFilters] CHECK CONSTRAINT [Employee_EmployeGroupFilter]
GO
/****** Object: ForeignKey [Group_EmployeGroupFilter] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[EmployeGroupFilters] WITH CHECK ADD CONSTRAINT [Group_EmployeGroupFilter] FOREIGN KEY([GroupID])
REFERENCES [dbo].[Group] ([GroupID])
GO
ALTER TABLE [dbo].[EmployeGroupFilters] CHECK CONSTRAINT [Group_EmployeGroupFilter]
GO
/****** Object: ForeignKey [Employee_LockedDate] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[LockedDates] WITH CHECK ADD CONSTRAINT [Employee_LockedDate] FOREIGN KEY([EmployeeID])
REFERENCES [dbo].[Employee] ([EmployeID])
GO
ALTER TABLE [dbo].[LockedDates] CHECK CONSTRAINT [Employee_LockedDate]
GO
/****** Object: ForeignKey [Schedule_Project] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Project] WITH CHECK ADD CONSTRAINT [Schedule_Project] FOREIGN KEY([ScheduleID])
REFERENCES [dbo].[Schedule] ([ScheduleID])
GO
ALTER TABLE [dbo].[Project] CHECK CONSTRAINT [Schedule_Project]
GO
/****** Object: ForeignKey [Employee_Schedule] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Schedule] WITH CHECK ADD CONSTRAINT [Employee_Schedule] FOREIGN KEY([EmployeID])
REFERENCES [dbo].[Employee] ([EmployeID])
GO
ALTER TABLE [dbo].[Schedule] CHECK CONSTRAINT [Employee_Schedule]
GO
/****** Object: ForeignKey [Recurring_Schedule] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Schedule] WITH CHECK ADD CONSTRAINT [Recurring_Schedule] FOREIGN KEY([RecurringID])
REFERENCES [dbo].[Recurring] ([RecurringID])
GO
ALTER TABLE [dbo].[Schedule] CHECK CONSTRAINT [Recurring_Schedule]
GO
/****** Object: ForeignKey [Project_Task] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Task] WITH CHECK ADD CONSTRAINT [Project_Task] FOREIGN KEY([ProjectID])
REFERENCES [dbo].[Project] ([ProjectID])
GO
ALTER TABLE [dbo].[Task] CHECK CONSTRAINT [Project_Task]
GO
/****** Object: ForeignKey [Schedule_Task] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Task] WITH CHECK ADD CONSTRAINT [Schedule_Task] FOREIGN KEY([ScheduleID])
REFERENCES [dbo].[Schedule] ([ScheduleID])
GO
ALTER TABLE [dbo].[Task] CHECK CONSTRAINT [Schedule_Task]
GO
/****** Object: ForeignKey [Schedule_Task1] Script Date: 04/24/2013 21:35:08 ******/
ALTER TABLE [dbo].[Task] WITH CHECK ADD CONSTRAINT [Schedule_Task1] FOREIGN KEY([ParentScheduleID])
REFERENCES [dbo].[Schedule] ([ScheduleID])
GO
ALTER TABLE [dbo].[Task] CHECK CONSTRAINT [Schedule_Task1]
GO
データベースがすでにセットアップされている可能性があるため、そこにドロップがあります。その場合、新しいコピーが必要です。
私は得る:
An exception occurred while executing a Transact-SQL statement or batch.
私がしていることに何か問題がありますか?スクリプトは、SQL Server で生成して取得しました。
私はそれがしたい:
1. Clear any tables, just empty the db.
2. Create the tables and foreign keys.
ありがとう