------------------------------------------------------------------------------
-- ADVANTAGE 2004.4.0
-- DB OBJECT CHANGES SINCE ADVANTAGE 2004.3.9
-- 05/09/2008
------------------------------------------------------------------------------



-------------------------------------------------------------------------------
-- NEW TABLES
-------------------------------------------------------------------------------

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Slu_AS_Volume_Discounts]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Slu_AS_Volume_Discounts]
GO

CREATE TABLE [dbo].[Slu_AS_Volume_Discounts] (
	[Slu_AS_Volume_Discounts_ID] [smallint] IDENTITY (1, 1) NOT NULL ,
	[Description] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
	[Sales_Qty] [decimal](9, 3) NULL ,
	[Discount_Perc] [decimal](9, 3) NULL ,
	[Date_Captured] [datetime] NULL ,
	[User_ID] [int] NULL ,
	[Touched] [timestamp] NULL ,
	[Slu_AW_Active_ID] [tinyint] NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Slu_AS_Volume_Discounts] WITH NOCHECK ADD 
	CONSTRAINT [PK_Slu_AS_Volume_Discounts] PRIMARY KEY  CLUSTERED 
	(
		[Slu_AS_Volume_Discounts_ID]
	)  ON [PRIMARY] 
GO

setuser
GO


EXEC sp_bindefault N'[dbo].[df_Numeric_Zero]', N'[Slu_AS_Volume_Discounts].[Sales_Qty]'
GO

EXEC sp_bindefault N'[dbo].[df_Numeric_Zero]', N'[Slu_AS_Volume_Discounts].[Discount_Perc]'
GO

EXEC sp_bindefault N'[dbo].[df_Date_Captured]', N'[Slu_AS_Volume_Discounts].[Date_Captured]'
GO

EXEC sp_bindefault N'[dbo].[df_Active]', N'[Slu_AS_Volume_Discounts].[Slu_AW_Active_ID]'
GO

EXEC sp_bindefault N'[dbo].[df_User_ID]', N'[Slu_AS_Volume_Discounts].[User_ID]'
GO

setuser
GO

-----------------------------------------

INSERT Slu_AS_Volume_Discounts
    (
        Description
    )
VALUES
    (
        '<None>'
    )

-----------------------------------------

-------------------------------------------------------------------------------
-- TABLE MODS
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
-- DELETE REDUNDANT TABLES
-------------------------------------------------------------------------------

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_AB_Generator_Tabs_AB_Generator]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[AB_Generator_Columns] DROP CONSTRAINT FK_AB_Generator_Tabs_AB_Generator
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_AB_Generator_Rows_AB_Generator]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[AB_Generator_Rows] DROP CONSTRAINT FK_AB_Generator_Rows_AB_Generator
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AB_Generator]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AB_Generator]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AB_Generator_Columns]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AB_Generator_Columns]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AB_Generator_Rows]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AB_Generator_Rows]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AB_Month_Account_Actuals]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AB_Month_Account_Actuals]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AB_Month_Account_Budgets]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AB_Month_Account_Budgets]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AC_Month_Sales_Actuals]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AC_Month_Sales_Actuals]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AC_Month_Sales_Budgets]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AC_Month_Sales_Budgets]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AO_Month_Orders_Actuals]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AO_Month_Orders_Actuals]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AO_Month_Orders_Budgets]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AO_Month_Orders_Budgets]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AP_Month_Sales_Actuals]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AP_Month_Sales_Actuals]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[AP_Month_Sales_Budgets]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[AP_Month_Sales_Budgets]
GO


----------------------------------------------------
--> NEW INDEXES
----------------------------------------------------




-------------------------------------------------------------------------------