--USE [pioner]

GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[components]') AND type in (N'U'))
BEGIN
	DELETE FROM dbo.components WHERE name='mdb.ph_history'
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_hystory_UserName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PH_HISTORY] DROP CONSTRAINT [DF_hystory_UserName]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_hystory_HostName]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PH_HISTORY] DROP CONSTRAINT [DF_hystory_HostName]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_hystory_ModifyDate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PH_HISTORY] DROP CONSTRAINT [DF_hystory_ModifyDate]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_hystory_OP_Code]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[PH_HISTORY] DROP CONSTRAINT [DF_hystory_OP_Code]
END

GO

/****** Object:  Table [dbo].[PH_HISTORY]    Script Date: 09/28/2012 15:06:28 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PH_HISTORY]') AND type in (N'U'))
DROP TABLE [dbo].[PH_HISTORY]
GO

/****** Object:  Trigger [History_Updated]    Script Date: 09/28/2012 14:36:46 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[History_Updated]'))
DROP TRIGGER [dbo].[History_Updated]
GO

/****** Object:  Trigger [History_Deleted]    Script Date: 09/28/2012 14:38:48 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[History_Deleted]'))
DROP TRIGGER [dbo].[History_Deleted]
GO

/****** Object:  Trigger [History_Inserted]    Script Date: 09/28/2012 14:39:02 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[History_Inserted]'))
DROP TRIGGER [dbo].[History_Inserted]
GO

/****** Object:  Trigger [History_Attr_Deleted]    Script Date: 09/28/2012 14:39:02 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[History_Attr_Deleted]'))
DROP TRIGGER [dbo].History_Attr_Deleted
GO

/****** Object:  Trigger [History_Attr_Inserted]    Script Date: 09/28/2012 14:39:02 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[History_Attr_Inserted]'))
DROP TRIGGER [dbo].History_Attr_Inserted
GO
