/*
Run this script on:

        ishq-rnd-sql1.Toms371GoldenWithRenamedFiles    -  This database will be modified

to synchronize it with:

        ishq-rnd-sql1.Insite.Commerce.UpgradeToGolden40

You are recommended to back up your database before running this script

Script created by SQL Compare version 11.5.0 from Red Gate Software Ltd at 3/16/2016 5:44:16 AM

*/
SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping extended properties'
GO
IF EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_Description', 'SCHEMA', N'dbo', 'TABLE', N'CategoryAttributeType', 'COLUMN', N'DetailDisplaySequence'))
EXEC sp_dropextendedproperty N'MS_Description', 'SCHEMA', N'dbo', 'TABLE', N'CategoryAttributeType', 'COLUMN', N'DetailDisplaySequence'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_Description', 'SCHEMA', N'dbo', 'TABLE', N'DictionaryAttribute', 'COLUMN', N'DisplayType'))
EXEC sp_dropextendedproperty N'MS_Description', 'SCHEMA', N'dbo', 'TABLE', N'DictionaryAttribute', 'COLUMN', N'DisplayType'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_DiagramPane1', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryLineView', NULL, NULL))
EXEC sp_dropextendedproperty N'MS_DiagramPane1', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryLineView', NULL, NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_DiagramPaneCount', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryLineView', NULL, NULL))
EXEC sp_dropextendedproperty N'MS_DiagramPaneCount', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryLineView', NULL, NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_DiagramPane1', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryView', NULL, NULL))
EXEC sp_dropextendedproperty N'MS_DiagramPane1', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryView', NULL, NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_DiagramPaneCount', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryView', NULL, NULL))
EXEC sp_dropextendedproperty N'MS_DiagramPaneCount', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryView', NULL, NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Affiliate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [FK_CustomerOrder_Affiliate]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_ApproverUserProfileId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [FK_CustomerOrder_ApproverUserProfileId]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [FK_CustomerOrder_Currency]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [FK_CustomerOrder_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_InitiatedByUserProfileId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [FK_CustomerOrder_InitiatedByUserProfileId]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_QuotedBy]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [FK_CustomerOrder_QuotedBy]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_ShipTo]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [FK_CustomerOrder_ShipTo]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [FK_CustomerOrder_ShipVia]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Subscription]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [FK_CustomerOrder_Subscription]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [FK_CustomerOrder_WebSite]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Salesman]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [FK_CustomerOrder_Salesman]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PromotionRule]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Affiliate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_Affiliate]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_PaymentTerm]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_PaymentTerm]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_Category]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_ContainedPromotion]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_ContainedPromotion]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Country]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_Country]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_Currency]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Promotion]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_Promotion]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_ShipVia]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_State]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_UserProfile]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Vendor]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_Vendor]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Salesman]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [FK_PromotionRule_Salesman]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[DictionaryAttribute]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DictionaryAttribute_ApplicationDictionary]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DictionaryAttribute]', 'U'))
ALTER TABLE [dbo].[DictionaryAttribute] DROP CONSTRAINT [FK_DictionaryAttribute_ApplicationDictionary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[DictionaryLabel]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DictionaryLabel_ApplicationDictionary]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DictionaryLabel]', 'U'))
ALTER TABLE [dbo].[DictionaryLabel] DROP CONSTRAINT [FK_DictionaryLabel_ApplicationDictionary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CategoryAttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryFilterSection_FilterSection]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U'))
ALTER TABLE [dbo].[CategoryAttributeType] DROP CONSTRAINT [FK_CategoryFilterSection_FilterSection]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryFilterSection_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U'))
ALTER TABLE [dbo].[CategoryAttributeType] DROP CONSTRAINT [FK_CategoryFilterSection_Category]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[AttributeValue]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_FilterValue_FilterSection]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[AttributeValue]', 'U'))
ALTER TABLE [dbo].[AttributeValue] DROP CONSTRAINT [FK_FilterValue_FilterSection]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CategoryAttributeValue]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryFilterValue_FilterValue]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryAttributeValue]', 'U'))
ALTER TABLE [dbo].[CategoryAttributeValue] DROP CONSTRAINT [FK_CategoryFilterValue_FilterValue]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryFilterValue_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryAttributeValue]', 'U'))
ALTER TABLE [dbo].[CategoryAttributeValue] DROP CONSTRAINT [FK_CategoryFilterValue_Category]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ProductAttributeValue]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductFilterValue_FilterValue]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductAttributeValue]', 'U'))
ALTER TABLE [dbo].[ProductAttributeValue] DROP CONSTRAINT [FK_ProductFilterValue_FilterValue]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductFilterValue_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductAttributeValue]', 'U'))
ALTER TABLE [dbo].[ProductAttributeValue] DROP CONSTRAINT [FK_ProductFilterValue_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[BudgetCalendar]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_BudgetCalendar_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[BudgetCalendar]', 'U'))
ALTER TABLE [dbo].[BudgetCalendar] DROP CONSTRAINT [FK_BudgetCalendar_Customer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CarrierPackage]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CarrierPackage_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierPackage]', 'U'))
ALTER TABLE [dbo].[CarrierPackage] DROP CONSTRAINT [FK_CarrierPackage_Carrier]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CarrierZonePostalCodeRange]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CarrierZoneZipCodeRange_CarrierZone]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierZonePostalCodeRange]', 'U'))
ALTER TABLE [dbo].[CarrierZonePostalCodeRange] DROP CONSTRAINT [FK_CarrierZoneZipCodeRange_CarrierZone]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CarrierZoneRate]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CarrierZoneRate_CarrierZone]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierZoneRate]', 'U'))
ALTER TABLE [dbo].[CarrierZoneRate] DROP CONSTRAINT [FK_CarrierZoneRate_CarrierZone]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CarrierZone]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CarrierZone_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierZone]', 'U'))
ALTER TABLE [dbo].[CarrierZone] DROP CONSTRAINT [FK_CarrierZone_Carrier]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Carrier]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Carrier_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U'))
ALTER TABLE [dbo].[Carrier] DROP CONSTRAINT [FK_Carrier_Carrier]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Carrier_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U'))
ALTER TABLE [dbo].[Carrier] DROP CONSTRAINT [FK_Carrier_Currency]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CategoryProductCrossSell]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryProductCrossSell_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProductCrossSell]', 'U'))
ALTER TABLE [dbo].[CategoryProductCrossSell] DROP CONSTRAINT [FK_CategoryProductCrossSell_Category]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryProductCrossSell_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProductCrossSell]', 'U'))
ALTER TABLE [dbo].[CategoryProductCrossSell] DROP CONSTRAINT [FK_CategoryProductCrossSell_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CategoryProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryProduct_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProduct]', 'U'))
ALTER TABLE [dbo].[CategoryProduct] DROP CONSTRAINT [FK_CategoryProduct_Category]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProduct]', 'U'))
ALTER TABLE [dbo].[CategoryProduct] DROP CONSTRAINT [FK_CategoryProduct_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CategoryProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryProperty_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProperty]', 'U'))
ALTER TABLE [dbo].[CategoryProperty] DROP CONSTRAINT [FK_CategoryProperty_Category]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CategorySpecification]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategorySpecification_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategorySpecification]', 'U'))
ALTER TABLE [dbo].[CategorySpecification] DROP CONSTRAINT [FK_CategorySpecification_Category]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategorySpecification_Specification]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategorySpecification]', 'U'))
ALTER TABLE [dbo].[CategorySpecification] DROP CONSTRAINT [FK_CategorySpecification_Specification]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CategoryTaxExemption]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryTaxExemption_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryTaxExemption]', 'U'))
ALTER TABLE [dbo].[CategoryTaxExemption] DROP CONSTRAINT [FK_CategoryTaxExemption_Category]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryTaxExemption_TaxExemption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryTaxExemption]', 'U'))
ALTER TABLE [dbo].[CategoryTaxExemption] DROP CONSTRAINT [FK_CategoryTaxExemption_TaxExemption]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category_DocumentManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Category]', 'U'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [FK_Category_DocumentManager]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category_RuleManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Category]', 'U'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [FK_Category_RuleManager]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Category]', 'U'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [FK_Category_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[City]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_City_County]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[City]', 'U'))
ALTER TABLE [dbo].[City] DROP CONSTRAINT [FK_City_County]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Company]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Company_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Company]', 'U'))
ALTER TABLE [dbo].[Company] DROP CONSTRAINT [FK_Company_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ConfigurationConditionFilter]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ConfigurationConditionFilter_ConfigurationOptionCondition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationConditionFilter]', 'U'))
ALTER TABLE [dbo].[ConfigurationConditionFilter] DROP CONSTRAINT [FK_ConfigurationConditionFilter_ConfigurationOptionCondition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ConfigurationOptionCondition]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ConfigurationOptionCondition_ConfigurationOption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationOptionCondition]', 'U'))
ALTER TABLE [dbo].[ConfigurationOptionCondition] DROP CONSTRAINT [FK_ConfigurationOptionCondition_ConfigurationOption]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ConfigurationPage]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ConfigurationPage_Configuration]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U'))
ALTER TABLE [dbo].[ConfigurationPage] DROP CONSTRAINT [FK_ConfigurationPage_Configuration]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ConfigurationQueryResultField]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ConfigurationQueryResultField_ConfigurationQueryResult]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationQueryResultField]', 'U'))
ALTER TABLE [dbo].[ConfigurationQueryResultField] DROP CONSTRAINT [FK_ConfigurationQueryResultField_ConfigurationQueryResult]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ConfigurationQueryResultValue]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ConfigurationQueryResultValue_ConfigurationQueryResult]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationQueryResultValue]', 'U'))
ALTER TABLE [dbo].[ConfigurationQueryResultValue] DROP CONSTRAINT [FK_ConfigurationQueryResultValue_ConfigurationQueryResult]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ContentItemField]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItemField_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U'))
ALTER TABLE [dbo].[ContentItemField] DROP CONSTRAINT [FK_ContentItemField_Language]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItemField_Persona]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U'))
ALTER TABLE [dbo].[ContentItemField] DROP CONSTRAINT [FK_ContentItemField_Persona]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItemField_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U'))
ALTER TABLE [dbo].[ContentItemField] DROP CONSTRAINT [FK_ContentItemField_UserProfile]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItemField_UserProfile1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U'))
ALTER TABLE [dbo].[ContentItemField] DROP CONSTRAINT [FK_ContentItemField_UserProfile1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ContentItem]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItem_UserProfile_ApprovedById]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U'))
ALTER TABLE [dbo].[ContentItem] DROP CONSTRAINT [FK_ContentItem_UserProfile_ApprovedById]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItem_UserProfile_CreatedById]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U'))
ALTER TABLE [dbo].[ContentItem] DROP CONSTRAINT [FK_ContentItem_UserProfile_CreatedById]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItem_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U'))
ALTER TABLE [dbo].[ContentItem] DROP CONSTRAINT [FK_ContentItem_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ContentPageState]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentPageState_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentPageState]', 'U'))
ALTER TABLE [dbo].[ContentPageState] DROP CONSTRAINT [FK_ContentPageState_Language]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentPageState_Persona]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentPageState]', 'U'))
ALTER TABLE [dbo].[ContentPageState] DROP CONSTRAINT [FK_ContentPageState_Persona]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentPageState_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentPageState]', 'U'))
ALTER TABLE [dbo].[ContentPageState] DROP CONSTRAINT [FK_ContentPageState_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Content]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Content_ApprovedBy]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Content]', 'U'))
ALTER TABLE [dbo].[Content] DROP CONSTRAINT [FK_Content_ApprovedBy]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Content_ContentManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Content]', 'U'))
ALTER TABLE [dbo].[Content] DROP CONSTRAINT [FK_Content_ContentManager]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Content_CreatedBy]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Content]', 'U'))
ALTER TABLE [dbo].[Content] DROP CONSTRAINT [FK_Content_CreatedBy]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Content_Persona]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Content]', 'U'))
ALTER TABLE [dbo].[Content] DROP CONSTRAINT [FK_Content_Persona]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[County]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_County_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[County]', 'U'))
ALTER TABLE [dbo].[County] DROP CONSTRAINT [FK_County_State]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CreditCardTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CreditCardTransaction_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]', 'U'))
ALTER TABLE [dbo].[CreditCardTransaction] DROP CONSTRAINT [FK_CreditCardTransaction_Currency]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CreditCardTransaction_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]', 'U'))
ALTER TABLE [dbo].[CreditCardTransaction] DROP CONSTRAINT [FK_CreditCardTransaction_CustomerOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CurrencyRate]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CurrencyRate_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CurrencyRate]', 'U'))
ALTER TABLE [dbo].[CurrencyRate] DROP CONSTRAINT [FK_CurrencyRate_Currency]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerBudget]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerBudget_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerBudget]', 'U'))
ALTER TABLE [dbo].[CustomerBudget] DROP CONSTRAINT [FK_CustomerBudget_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerBudget_ShipToCustomer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerBudget]', 'U'))
ALTER TABLE [dbo].[CustomerBudget] DROP CONSTRAINT [FK_CustomerBudget_ShipToCustomer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerBudget_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerBudget]', 'U'))
ALTER TABLE [dbo].[CustomerBudget] DROP CONSTRAINT [FK_CustomerBudget_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerCarrier]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerCarrier_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerCarrier]', 'U'))
ALTER TABLE [dbo].[CustomerCarrier] DROP CONSTRAINT [FK_CustomerCarrier_Carrier]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerCarrier_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerCarrier]', 'U'))
ALTER TABLE [dbo].[CustomerCarrier] DROP CONSTRAINT [FK_CustomerCarrier_Customer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerCostCode]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerCostCode_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerCostCode]', 'U'))
ALTER TABLE [dbo].[CustomerCostCode] DROP CONSTRAINT [FK_CustomerCostCode_Customer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerDiscount]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerDiscount_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerDiscount]', 'U'))
ALTER TABLE [dbo].[CustomerDiscount] DROP CONSTRAINT [FK_CustomerDiscount_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerDiscount_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerDiscount]', 'U'))
ALTER TABLE [dbo].[CustomerDiscount] DROP CONSTRAINT [FK_CustomerDiscount_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerOrderGiftCard]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrderGiftCard_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrderGiftCard]', 'U'))
ALTER TABLE [dbo].[CustomerOrderGiftCard] DROP CONSTRAINT [FK_CustomerOrderGiftCard_CustomerOrder]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrderGiftCard_GiftCard]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrderGiftCard]', 'U'))
ALTER TABLE [dbo].[CustomerOrderGiftCard] DROP CONSTRAINT [FK_CustomerOrderGiftCard_GiftCard]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerOrderPromotion]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrderPromotion_CustomerOrderId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrderPromotion]', 'U'))
ALTER TABLE [dbo].[CustomerOrderPromotion] DROP CONSTRAINT [FK_CustomerOrderPromotion_CustomerOrderId]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrderPromotion_PromotionId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrderPromotion]', 'U'))
ALTER TABLE [dbo].[CustomerOrderPromotion] DROP CONSTRAINT [FK_CustomerOrderPromotion_PromotionId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerOrderProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DCustomerOrderProperty_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrderProperty]', 'U'))
ALTER TABLE [dbo].[CustomerOrderProperty] DROP CONSTRAINT [FK_DCustomerOrderProperty_CustomerOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProductPrice_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U'))
ALTER TABLE [dbo].[CustomerProductPrice] DROP CONSTRAINT [FK_CustomerProductPrice_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProductPrice_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U'))
ALTER TABLE [dbo].[CustomerProductPrice] DROP CONSTRAINT [FK_CustomerProductPrice_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerProductSetProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProductSetProduct_CustomerProductSet]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProductSetProduct]', 'U'))
ALTER TABLE [dbo].[CustomerProductSetProduct] DROP CONSTRAINT [FK_CustomerProductSetProduct_CustomerProductSet]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProductSetProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProductSetProduct]', 'U'))
ALTER TABLE [dbo].[CustomerProductSetProduct] DROP CONSTRAINT [FK_CustomerProductSetProduct_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerProductSet]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProductSet_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]', 'U'))
ALTER TABLE [dbo].[CustomerProductSet] DROP CONSTRAINT [FK_CustomerProductSet_Customer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProduct_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProduct]', 'U'))
ALTER TABLE [dbo].[CustomerProduct] DROP CONSTRAINT [FK_CustomerProduct_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProduct]', 'U'))
ALTER TABLE [dbo].[CustomerProduct] DROP CONSTRAINT [FK_CustomerProduct_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProperty_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProperty]', 'U'))
ALTER TABLE [dbo].[CustomerProperty] DROP CONSTRAINT [FK_CustomerProperty_Customer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[CustomerUserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerUserProfile_CustomerId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerUserProfile]', 'U'))
ALTER TABLE [dbo].[CustomerUserProfile] DROP CONSTRAINT [FK_CustomerUserProfile_CustomerId]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerUserProfile_UserProfileId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerUserProfile]', 'U'))
ALTER TABLE [dbo].[CustomerUserProfile] DROP CONSTRAINT [FK_CustomerUserProfile_UserProfileId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Company1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [FK_Customer_Company1]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Country]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [FK_Customer_Country]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [FK_Customer_Currency]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [FK_Customer_State]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PricingCustomer_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [FK_PricingCustomer_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Salesman]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [FK_Customer_Salesman]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[DashboardPanelPosition]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DashboardPanelPosition_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DashboardPanelPosition]', 'U'))
ALTER TABLE [dbo].[DashboardPanelPosition] DROP CONSTRAINT [FK_DashboardPanelPosition_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[DealerCategory]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DealerCategory_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DealerCategory]', 'U'))
ALTER TABLE [dbo].[DealerCategory] DROP CONSTRAINT [FK_DealerCategory_Category]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DealerCategory_Dealer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DealerCategory]', 'U'))
ALTER TABLE [dbo].[DealerCategory] DROP CONSTRAINT [FK_DealerCategory_Dealer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[DealerProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DealerProduct_Dealer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DealerProduct]', 'U'))
ALTER TABLE [dbo].[DealerProduct] DROP CONSTRAINT [FK_DealerProduct_Dealer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DealerProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DealerProduct]', 'U'))
ALTER TABLE [dbo].[DealerProduct] DROP CONSTRAINT [FK_DealerProduct_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[DealerProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DealerProperty_Dealer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DealerProperty]', 'U'))
ALTER TABLE [dbo].[DealerProperty] DROP CONSTRAINT [FK_DealerProperty_Dealer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Document]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Document_DocumentManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Document]', 'U'))
ALTER TABLE [dbo].[Document] DROP CONSTRAINT [FK_Document_DocumentManager]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[EmailList]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailList_EmailTemplate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailList]', 'U'))
ALTER TABLE [dbo].[EmailList] DROP CONSTRAINT [FK_EmailList_EmailTemplate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[EmailMessageAddress]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailMessageAddress_EmailMessage]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailMessageAddress]', 'U'))
ALTER TABLE [dbo].[EmailMessageAddress] DROP CONSTRAINT [FK_EmailMessageAddress_EmailMessage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[EmailMessageDeliveryAttempt]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailMessageDeliveryAttempt_EmailMessage]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailMessageDeliveryAttempt]', 'U'))
ALTER TABLE [dbo].[EmailMessageDeliveryAttempt] DROP CONSTRAINT [FK_EmailMessageDeliveryAttempt_EmailMessage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[EmailSubscriberEmailList]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailSubscriberEmailList_EmailList]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailSubscriberEmailList]', 'U'))
ALTER TABLE [dbo].[EmailSubscriberEmailList] DROP CONSTRAINT [FK_EmailSubscriberEmailList_EmailList]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailSubscriberEmailList_EmailSubscriber]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailSubscriberEmailList]', 'U'))
ALTER TABLE [dbo].[EmailSubscriberEmailList] DROP CONSTRAINT [FK_EmailSubscriberEmailList_EmailSubscriber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[EmailTemplate]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailTemplate_ContentManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailTemplate]', 'U'))
ALTER TABLE [dbo].[EmailTemplate] DROP CONSTRAINT [FK_EmailTemplate_ContentManager]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[GiftCardTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_GiftCardTransaction_GiftCard]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[GiftCardTransaction]', 'U'))
ALTER TABLE [dbo].[GiftCardTransaction] DROP CONSTRAINT [FK_GiftCardTransaction_GiftCard]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[GiftCard]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_GiftCard_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[GiftCard]', 'U'))
ALTER TABLE [dbo].[GiftCard] DROP CONSTRAINT [FK_GiftCard_Currency]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_GiftCard_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[GiftCard]', 'U'))
ALTER TABLE [dbo].[GiftCard] DROP CONSTRAINT [FK_GiftCard_OrderLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[IntegrationJobLog]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobLog_IntegrationJob]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationJobLog]', 'U'))
ALTER TABLE [dbo].[IntegrationJobLog] DROP CONSTRAINT [FK_IntegrationJobLog_IntegrationJob]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[IntegrationJobParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobParameter_IntegrationJob]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationJobParameter]', 'U'))
ALTER TABLE [dbo].[IntegrationJobParameter] DROP CONSTRAINT [FK_IntegrationJobParameter_IntegrationJob]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobParameter_IntegrationJobDefinitionStepParameter]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationJobParameter]', 'U'))
ALTER TABLE [dbo].[IntegrationJobParameter] DROP CONSTRAINT [FK_IntegrationJobParameter_IntegrationJobDefinitionStepParameter]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJob_IntegrationJobDefinition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U'))
ALTER TABLE [dbo].[IntegrationJob] DROP CONSTRAINT [FK_IntegrationJob_IntegrationJobDefinition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[InventoryTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_InventoryTransaction_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[InventoryTransaction]', 'U'))
ALTER TABLE [dbo].[InventoryTransaction] DROP CONSTRAINT [FK_InventoryTransaction_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[InvoiceHistoryLine]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_InvoiceHistoryLine_InvoiceHistory]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[InvoiceHistoryLine]', 'U'))
ALTER TABLE [dbo].[InvoiceHistoryLine] DROP CONSTRAINT [FK_InvoiceHistoryLine_InvoiceHistory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_InvoiceLine_Invoice]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [FK_InvoiceLine_Invoice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Invoice_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [FK_Invoice_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Invoice_Customer1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [FK_Invoice_Customer1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[JobDefinitionParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobDefinitionPostprocessorParameter_IntegrationJobDefinition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U'))
ALTER TABLE [dbo].[JobDefinitionParameter] DROP CONSTRAINT [FK_IntegrationJobDefinitionPostprocessorParameter_IntegrationJobDefinition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[JobDefinitionStepFieldMap]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobDefinitionStepFieldMap_IntegrationJobDefinitionStep]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] DROP CONSTRAINT [FK_IntegrationJobDefinitionStepFieldMap_IntegrationJobDefinitionStep]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[JobDefinitionStepParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobDefinitionStepParameter_IntegrationJobDefinitionStep]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] DROP CONSTRAINT [FK_IntegrationJobDefinitionStepParameter_IntegrationJobDefinitionStep]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobDefinitionStep_IntegrationJobDefinition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [FK_IntegrationJobDefinitionStep_IntegrationJobDefinition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobDefinition_IntegrationJobDefinition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [FK_IntegrationJobDefinition_IntegrationJobDefinition]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobDefinition_EmailTemplate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [FK_IntegrationJobDefinition_EmailTemplate]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobDefinition_IntegrationConnection]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [FK_IntegrationJobDefinition_IntegrationConnection]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[LocalTaxRateTaxExemption]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_LocalTaxRateTaxExemption_LocalTaxRate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[LocalTaxRateTaxExemption]', 'U'))
ALTER TABLE [dbo].[LocalTaxRateTaxExemption] DROP CONSTRAINT [FK_LocalTaxRateTaxExemption_LocalTaxRate]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_LocalTaxRateTaxExemption_TaxExemption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[LocalTaxRateTaxExemption]', 'U'))
ALTER TABLE [dbo].[LocalTaxRateTaxExemption] DROP CONSTRAINT [FK_LocalTaxRateTaxExemption_TaxExemption]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[MenuRole]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MenuRole_Menu]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MenuRole]', 'U'))
ALTER TABLE [dbo].[MenuRole] DROP CONSTRAINT [FK_MenuRole_Menu]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Menu]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Menu_Menu]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Menu]', 'U'))
ALTER TABLE [dbo].[Menu] DROP CONSTRAINT [FK_Menu_Menu]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[MessageAudit]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageAudit_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U'))
ALTER TABLE [dbo].[MessageAudit] DROP CONSTRAINT [FK_MessageAudit_CustomerOrder]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageAudit_FromUserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U'))
ALTER TABLE [dbo].[MessageAudit] DROP CONSTRAINT [FK_MessageAudit_FromUserProfile]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageAudit_Message]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U'))
ALTER TABLE [dbo].[MessageAudit] DROP CONSTRAINT [FK_MessageAudit_Message]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageAudit_ToUserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U'))
ALTER TABLE [dbo].[MessageAudit] DROP CONSTRAINT [FK_MessageAudit_ToUserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[MessageStatus]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageStatus_Message]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageStatus]', 'U'))
ALTER TABLE [dbo].[MessageStatus] DROP CONSTRAINT [FK_MessageStatus_Message]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageStatus_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageStatus]', 'U'))
ALTER TABLE [dbo].[MessageStatus] DROP CONSTRAINT [FK_MessageStatus_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[MessageTarget]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageTarget_Message]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageTarget]', 'U'))
ALTER TABLE [dbo].[MessageTarget] DROP CONSTRAINT [FK_MessageTarget_Message]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[MiscellaneousCode]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MiscellaneousCode_MiscellaneousCode]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MiscellaneousCode]', 'U'))
ALTER TABLE [dbo].[MiscellaneousCode] DROP CONSTRAINT [FK_MiscellaneousCode_MiscellaneousCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[NewsArticle]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_NewsArticle_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[NewsArticle]', 'U'))
ALTER TABLE [dbo].[NewsArticle] DROP CONSTRAINT [FK_NewsArticle_UserProfile]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_NewsArticle_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[NewsArticle]', 'U'))
ALTER TABLE [dbo].[NewsArticle] DROP CONSTRAINT [FK_NewsArticle_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[OrderHistoryLine]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderHistoryLine_OrderHistory]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderHistoryLine]', 'U'))
ALTER TABLE [dbo].[OrderHistoryLine] DROP CONSTRAINT [FK_OrderHistoryLine_OrderHistory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[OrderLineConfigurationValue]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineConfigurationValue_ConfigurationOption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineConfigurationValue]', 'U'))
ALTER TABLE [dbo].[OrderLineConfigurationValue] DROP CONSTRAINT [FK_OrderLineConfigurationValue_ConfigurationOption]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineConfigurationValue_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineConfigurationValue]', 'U'))
ALTER TABLE [dbo].[OrderLineConfigurationValue] DROP CONSTRAINT [FK_OrderLineConfigurationValue_OrderLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[OrderLineProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineAttribute_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]', 'U'))
ALTER TABLE [dbo].[OrderLineProperty] DROP CONSTRAINT [FK_OrderLineAttribute_OrderLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[OrderLineRequisition]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineRequisition_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]', 'U'))
ALTER TABLE [dbo].[OrderLineRequisition] DROP CONSTRAINT [FK_OrderLineRequisition_OrderLine]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineRequisition_OrderLineRequisition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]', 'U'))
ALTER TABLE [dbo].[OrderLineRequisition] DROP CONSTRAINT [FK_OrderLineRequisition_OrderLineRequisition]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineRequisition_OriginalOrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]', 'U'))
ALTER TABLE [dbo].[OrderLineRequisition] DROP CONSTRAINT [FK_OrderLineRequisition_OriginalOrderLine]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineRequisition_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]', 'U'))
ALTER TABLE [dbo].[OrderLineRequisition] DROP CONSTRAINT [FK_OrderLineRequisition_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[OrderLineRfq]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineRfq_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRfq]', 'U'))
ALTER TABLE [dbo].[OrderLineRfq] DROP CONSTRAINT [FK_OrderLineRfq_OrderLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[OrderLine]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLine_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] DROP CONSTRAINT [FK_OrderLine_CustomerOrder]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLine_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] DROP CONSTRAINT [FK_OrderLine_OrderLine]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLine_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] DROP CONSTRAINT [FK_OrderLine_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLine_PromotionResult]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] DROP CONSTRAINT [FK_OrderLine_PromotionResult]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLine_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] DROP CONSTRAINT [FK_OrderLine_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[OrderPromotionCode]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionCode_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderPromotionCode]', 'U'))
ALTER TABLE [dbo].[OrderPromotionCode] DROP CONSTRAINT [FK_PromotionCode_CustomerOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Persona]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Persona_RuleManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Persona]', 'U'))
ALTER TABLE [dbo].[Persona] DROP CONSTRAINT [FK_Persona_RuleManager]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ProductCost]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductCost_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductCost]', 'U'))
ALTER TABLE [dbo].[ProductCost] DROP CONSTRAINT [FK_ProductCost_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductPrice_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [FK_ProductPrice_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ProductProductAccessory]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[ProductProductAccessory_fk]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductProductAccessory]', 'U'))
ALTER TABLE [dbo].[ProductProductAccessory] DROP CONSTRAINT [ProductProductAccessory_fk]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ProductProductCrossSell]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductProductCrossSell_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductProductCrossSell]', 'U'))
ALTER TABLE [dbo].[ProductProductCrossSell] DROP CONSTRAINT [FK_ProductProductCrossSell_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductProductCrossSell_Product1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductProductCrossSell]', 'U'))
ALTER TABLE [dbo].[ProductProductCrossSell] DROP CONSTRAINT [FK_ProductProductCrossSell_Product1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ProductProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductProperty_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductProperty]', 'U'))
ALTER TABLE [dbo].[ProductProperty] DROP CONSTRAINT [FK_ProductProperty_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ProductSpecification]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductSpecification_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductSpecification]', 'U'))
ALTER TABLE [dbo].[ProductSpecification] DROP CONSTRAINT [FK_ProductSpecification_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductSpecification_Specification]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductSpecification]', 'U'))
ALTER TABLE [dbo].[ProductSpecification] DROP CONSTRAINT [FK_ProductSpecification_Specification]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ProductTaxExemption]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductTaxExemption_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductTaxExemption]', 'U'))
ALTER TABLE [dbo].[ProductTaxExemption] DROP CONSTRAINT [FK_ProductTaxExemption_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductTaxExemption_TaxExemption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductTaxExemption]', 'U'))
ALTER TABLE [dbo].[ProductTaxExemption] DROP CONSTRAINT [FK_ProductTaxExemption_TaxExemption]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ProductUnitOfMeasure]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductUnitOfMeasure_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]', 'U'))
ALTER TABLE [dbo].[ProductUnitOfMeasure] DROP CONSTRAINT [FK_ProductUnitOfMeasure_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ProductWarehouse]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductWarehouse_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductWarehouse]', 'U'))
ALTER TABLE [dbo].[ProductWarehouse] DROP CONSTRAINT [FK_ProductWarehouse_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductWarehouse_Warehouse]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductWarehouse]', 'U'))
ALTER TABLE [dbo].[ProductWarehouse] DROP CONSTRAINT [FK_ProductWarehouse_Warehouse]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_Configuration]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [FK_Product_Configuration]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_DocumentManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [FK_Product_DocumentManager]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_ReplacementProduct]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [FK_Product_ReplacementProduct]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_RestrictionGroup]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [FK_Product_RestrictionGroup]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [FK_Product_ShipVia]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_StyleClass]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [FK_Product_StyleClass]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_Vendor]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [FK_Product_Vendor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PromotionResult]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionResult_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionResult]', 'U'))
ALTER TABLE [dbo].[PromotionResult] DROP CONSTRAINT [FK_PromotionResult_Category]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionResult_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionResult]', 'U'))
ALTER TABLE [dbo].[PromotionResult] DROP CONSTRAINT [FK_PromotionResult_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionResult_Promotion]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionResult]', 'U'))
ALTER TABLE [dbo].[PromotionResult] DROP CONSTRAINT [FK_PromotionResult_Promotion]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionResult_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionResult]', 'U'))
ALTER TABLE [dbo].[PromotionResult] DROP CONSTRAINT [FK_PromotionResult_ShipVia]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PunchOutCustomerUserProfileMap]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutCustomerUserProfileMap_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutCustomerUserProfileMap]', 'U'))
ALTER TABLE [dbo].[PunchOutCustomerUserProfileMap] DROP CONSTRAINT [FK_PunchOutCustomerUserProfileMap_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutCustomerUserProfileMap_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutCustomerUserProfileMap]', 'U'))
ALTER TABLE [dbo].[PunchOutCustomerUserProfileMap] DROP CONSTRAINT [FK_PunchOutCustomerUserProfileMap_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PunchOutOrderRequestExtrinsic]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequestExtrinsic_PunchOutOrderRequest]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestExtrinsic]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestExtrinsic] DROP CONSTRAINT [FK_PunchOutOrderRequestExtrinsic_PunchOutOrderRequest]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PunchOutOrderRequestMessage]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequestValidationMessage_PunchOutOrderRequestItemOut]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] DROP CONSTRAINT [FK_PunchOutOrderRequestValidationMessage_PunchOutOrderRequestItemOut]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequestValidationMessage_PunchOutOrderRequest]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] DROP CONSTRAINT [FK_PunchOutOrderRequestValidationMessage_PunchOutOrderRequest]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PunchOutOrderRequestItemOut]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequestItemOut_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [FK_PunchOutOrderRequestItemOut_OrderLine]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequestItemOut_PunchOutOrderRequest]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [FK_PunchOutOrderRequestItemOut_PunchOutOrderRequest]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequest_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [FK_PunchOutOrderRequest_CustomerOrder]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequest_PunchOutSessionId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [FK_PunchOutOrderRequest_PunchOutSessionId]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequest_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [FK_PunchOutOrderRequest_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PunchOutSessionAccess]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSessionAccess_PunchOutSession]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSessionAccess]', 'U'))
ALTER TABLE [dbo].[PunchOutSessionAccess] DROP CONSTRAINT [FK_PunchOutSessionAccess_PunchOutSession]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PunchOutSessionExtrinsic]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSessionExtrinsic_PunchOutSession]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSessionExtrinsic]', 'U'))
ALTER TABLE [dbo].[PunchOutSessionExtrinsic] DROP CONSTRAINT [FK_PunchOutSessionExtrinsic_PunchOutSession]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PunchOutSessionItemIn]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSessionItemIn_PunchOutSession]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSessionItemIn]', 'U'))
ALTER TABLE [dbo].[PunchOutSessionItemIn] DROP CONSTRAINT [FK_PunchOutSessionItemIn_PunchOutSession]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PunchOutSession]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSession_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSession]', 'U'))
ALTER TABLE [dbo].[PunchOutSession] DROP CONSTRAINT [FK_PunchOutSession_CustomerOrder]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSession_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSession]', 'U'))
ALTER TABLE [dbo].[PunchOutSession] DROP CONSTRAINT [FK_PunchOutSession_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[PunchOutSetupRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSetupRequest_PunchOutSession]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSetupRequest]', 'U'))
ALTER TABLE [dbo].[PunchOutSetupRequest] DROP CONSTRAINT [FK_PunchOutSetupRequest_PunchOutSession]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Review]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Review_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Review]', 'U'))
ALTER TABLE [dbo].[Review] DROP CONSTRAINT [FK_Review_Category]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Review_ContentManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Review]', 'U'))
ALTER TABLE [dbo].[Review] DROP CONSTRAINT [FK_Review_ContentManager]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Review_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Review]', 'U'))
ALTER TABLE [dbo].[Review] DROP CONSTRAINT [FK_Review_UserProfile]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Review_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Review]', 'U'))
ALTER TABLE [dbo].[Review] DROP CONSTRAINT [FK_Review_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[RuleClause]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RuleClause_RuleManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleClause]', 'U'))
ALTER TABLE [dbo].[RuleClause] DROP CONSTRAINT [FK_RuleClause_RuleManager]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RuleClause_RuleTypeOption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleClause]', 'U'))
ALTER TABLE [dbo].[RuleClause] DROP CONSTRAINT [FK_RuleClause_RuleTypeOption]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[RuleManager]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RuleManager_RuleType]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleManager]', 'U'))
ALTER TABLE [dbo].[RuleManager] DROP CONSTRAINT [FK_RuleManager_RuleType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[RuleTypeOption]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RuleTypeOption_RuleType]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleTypeOption]', 'U'))
ALTER TABLE [dbo].[RuleTypeOption] DROP CONSTRAINT [FK_RuleTypeOption_RuleType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Salesman_Salesman]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [FK_Salesman_Salesman]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Salesman_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [FK_Salesman_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ShipCharge]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipCharge_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipCharge]', 'U'))
ALTER TABLE [dbo].[ShipCharge] DROP CONSTRAINT [FK_ShipCharge_Carrier]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipCharge_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipCharge]', 'U'))
ALTER TABLE [dbo].[ShipCharge] DROP CONSTRAINT [FK_ShipCharge_ShipVia]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ShipRate]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRate_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRate]', 'U'))
ALTER TABLE [dbo].[ShipRate] DROP CONSTRAINT [FK_ShipRate_ShipVia]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ShipRule]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] DROP CONSTRAINT [FK_ShipRule_Carrier]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] DROP CONSTRAINT [FK_ShipRule_Category]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_Country]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] DROP CONSTRAINT [FK_ShipRule_Country]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] DROP CONSTRAINT [FK_ShipRule_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] DROP CONSTRAINT [FK_ShipRule_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_ShipRate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] DROP CONSTRAINT [FK_ShipRule_ShipRate]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] DROP CONSTRAINT [FK_ShipRule_ShipVia]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] DROP CONSTRAINT [FK_ShipRule_State]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ShipVia]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipVia_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipVia]', 'U'))
ALTER TABLE [dbo].[ShipVia] DROP CONSTRAINT [FK_ShipVia_Carrier]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ShipmentPackageLine]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PackageLine_ShipmentPackage]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U'))
ALTER TABLE [dbo].[ShipmentPackageLine] DROP CONSTRAINT [FK_PackageLine_ShipmentPackage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ShipmentPackage]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipmentPackage_Shipment]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipmentPackage]', 'U'))
ALTER TABLE [dbo].[ShipmentPackage] DROP CONSTRAINT [FK_ShipmentPackage_Shipment]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[ShippingRestriction]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Restriction_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U'))
ALTER TABLE [dbo].[ShippingRestriction] DROP CONSTRAINT [FK_Restriction_Category]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Restriction_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U'))
ALTER TABLE [dbo].[ShippingRestriction] DROP CONSTRAINT [FK_Restriction_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Restriction_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U'))
ALTER TABLE [dbo].[ShippingRestriction] DROP CONSTRAINT [FK_Restriction_State]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[StateTaxExemption]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StateTaxExemption_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StateTaxExemption]', 'U'))
ALTER TABLE [dbo].[StateTaxExemption] DROP CONSTRAINT [FK_StateTaxExemption_State]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StateTaxExemption_TaxExemption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StateTaxExemption]', 'U'))
ALTER TABLE [dbo].[StateTaxExemption] DROP CONSTRAINT [FK_StateTaxExemption_TaxExemption]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[StyleTraitValueProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StyleTraitValueProduct_Product1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StyleTraitValueProduct]', 'U'))
ALTER TABLE [dbo].[StyleTraitValueProduct] DROP CONSTRAINT [FK_StyleTraitValueProduct_Product1]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StyleTraitValueProduct_StyleTraitValue1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StyleTraitValueProduct]', 'U'))
ALTER TABLE [dbo].[StyleTraitValueProduct] DROP CONSTRAINT [FK_StyleTraitValueProduct_StyleTraitValue1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[StyleTraitValue]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StyleTraitValue_StyleTrait1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StyleTraitValue]', 'U'))
ALTER TABLE [dbo].[StyleTraitValue] DROP CONSTRAINT [FK_StyleTraitValue_StyleTrait1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[StyleTrait]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StyleTrait_StyleClass]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StyleTrait]', 'U'))
ALTER TABLE [dbo].[StyleTrait] DROP CONSTRAINT [FK_StyleTrait_StyleClass]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[SubscriptionLine]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SubscriptionLine_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[SubscriptionLine]', 'U'))
ALTER TABLE [dbo].[SubscriptionLine] DROP CONSTRAINT [FK_SubscriptionLine_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SubscriptionLine_Subscription]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[SubscriptionLine]', 'U'))
ALTER TABLE [dbo].[SubscriptionLine] DROP CONSTRAINT [FK_SubscriptionLine_Subscription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[SubscriptionProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SubscriptionProduct_ParentProduct]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[SubscriptionProduct]', 'U'))
ALTER TABLE [dbo].[SubscriptionProduct] DROP CONSTRAINT [FK_SubscriptionProduct_ParentProduct]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SubscriptionProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[SubscriptionProduct]', 'U'))
ALTER TABLE [dbo].[SubscriptionProduct] DROP CONSTRAINT [FK_SubscriptionProduct_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [FK_Subscription_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [FK_Subscription_CustomerOrder]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [FK_Subscription_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_ShipTo]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [FK_Subscription_ShipTo]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [FK_Subscription_ShipVia]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [FK_Subscription_UserProfile]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [FK_Subscription_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[UserProfileEmailList]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfileEmailList_EmailList]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfileEmailList]', 'U'))
ALTER TABLE [dbo].[UserProfileEmailList] DROP CONSTRAINT [FK_UserProfileEmailList_EmailList]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfileEmailList_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfileEmailList]', 'U'))
ALTER TABLE [dbo].[UserProfileEmailList] DROP CONSTRAINT [FK_UserProfileEmailList_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[UserProfilePassword]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfilePassword_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfilePassword]', 'U'))
ALTER TABLE [dbo].[UserProfilePassword] DROP CONSTRAINT [FK_UserProfilePassword_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[UserProfileProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfileProperty_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfileProperty]', 'U'))
ALTER TABLE [dbo].[UserProfileProperty] DROP CONSTRAINT [FK_UserProfileProperty_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfile_ApproverUserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [FK_UserProfile_ApproverUserProfile]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfile_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [FK_UserProfile_Currency]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfile_DefaultCustomer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [FK_UserProfile_DefaultCustomer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WarehouseAlternate]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WarehouseAlternate_AlternateWarehouse]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WarehouseAlternate]', 'U'))
ALTER TABLE [dbo].[WarehouseAlternate] DROP CONSTRAINT [FK_WarehouseAlternate_AlternateWarehouse]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WarehouseAlternate_Warehouse]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WarehouseAlternate]', 'U'))
ALTER TABLE [dbo].[WarehouseAlternate] DROP CONSTRAINT [FK_WarehouseAlternate_Warehouse]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebPageContent]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebPageContent_WebPage]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebPageContent]', 'U'))
ALTER TABLE [dbo].[WebPageContent] DROP CONSTRAINT [FK_WebPageContent_WebPage]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebPageContent_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebPageContent]', 'U'))
ALTER TABLE [dbo].[WebPageContent] DROP CONSTRAINT [FK_WebPageContent_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebPage]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebPage_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebPage]', 'U'))
ALTER TABLE [dbo].[WebPage] DROP CONSTRAINT [FK_WebPage_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebSiteAllowedCustomers]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteAllowedCustomers_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteAllowedCustomers]', 'U'))
ALTER TABLE [dbo].[WebSiteAllowedCustomers] DROP CONSTRAINT [FK_WebSiteAllowedCustomers_Customer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteAllowedCustomers_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteAllowedCustomers]', 'U'))
ALTER TABLE [dbo].[WebSiteAllowedCustomers] DROP CONSTRAINT [FK_WebSiteAllowedCustomers_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebSiteCarrier]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCarrier_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCarrier]', 'U'))
ALTER TABLE [dbo].[WebSiteCarrier] DROP CONSTRAINT [FK_WebSiteCarrier_Carrier]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCarrier_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCarrier]', 'U'))
ALTER TABLE [dbo].[WebSiteCarrier] DROP CONSTRAINT [FK_WebSiteCarrier_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebSiteConfiguration]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteConfiguration_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteConfiguration]', 'U'))
ALTER TABLE [dbo].[WebSiteConfiguration] DROP CONSTRAINT [FK_WebSiteConfiguration_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebSiteCountry]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCountry_Country]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCountry]', 'U'))
ALTER TABLE [dbo].[WebSiteCountry] DROP CONSTRAINT [FK_WebSiteCountry_Country]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCountry_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCountry]', 'U'))
ALTER TABLE [dbo].[WebSiteCountry] DROP CONSTRAINT [FK_WebSiteCountry_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebSiteCurrency]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCurrency_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCurrency]', 'U'))
ALTER TABLE [dbo].[WebSiteCurrency] DROP CONSTRAINT [FK_WebSiteCurrency_Currency]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCurrency_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCurrency]', 'U'))
ALTER TABLE [dbo].[WebSiteCurrency] DROP CONSTRAINT [FK_WebSiteCurrency_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebSiteDealer]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteDealer_Dealer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteDealer]', 'U'))
ALTER TABLE [dbo].[WebSiteDealer] DROP CONSTRAINT [FK_WebSiteDealer_Dealer]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteDealer_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteDealer]', 'U'))
ALTER TABLE [dbo].[WebSiteDealer] DROP CONSTRAINT [FK_WebSiteDealer_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebSiteLanguage]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteLanguage_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteLanguage]', 'U'))
ALTER TABLE [dbo].[WebSiteLanguage] DROP CONSTRAINT [FK_WebSiteLanguage_Language]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteLanguage_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteLanguage]', 'U'))
ALTER TABLE [dbo].[WebSiteLanguage] DROP CONSTRAINT [FK_WebSiteLanguage_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebSiteProductCrossSell]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteProductCrossSell_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteProductCrossSell]', 'U'))
ALTER TABLE [dbo].[WebSiteProductCrossSell] DROP CONSTRAINT [FK_WebSiteProductCrossSell_Product]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteProductCrossSell_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteProductCrossSell]', 'U'))
ALTER TABLE [dbo].[WebSiteProductCrossSell] DROP CONSTRAINT [FK_WebSiteProductCrossSell_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebSitePromotion]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSitePromotion_Promotion]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSitePromotion]', 'U'))
ALTER TABLE [dbo].[WebSitePromotion] DROP CONSTRAINT [FK_WebSitePromotion_Promotion]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSitePromotion_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSitePromotion]', 'U'))
ALTER TABLE [dbo].[WebSitePromotion] DROP CONSTRAINT [FK_WebSitePromotion_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebSiteState]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteState_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteState]', 'U'))
ALTER TABLE [dbo].[WebSiteState] DROP CONSTRAINT [FK_WebSiteState_State]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteState_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteState]', 'U'))
ALTER TABLE [dbo].[WebSiteState] DROP CONSTRAINT [FK_WebSiteState_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSite_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [FK_WebSite_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WishListProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_Id]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WishListProduct]', 'U'))
ALTER TABLE [dbo].[WishListProduct] DROP CONSTRAINT [FK_Product_Id]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WishList_Id]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WishListProduct]', 'U'))
ALTER TABLE [dbo].[WishListProduct] DROP CONSTRAINT [FK_WishList_Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[WishList]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfileId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WishList]', 'U'))
ALTER TABLE [dbo].[WishList] DROP CONSTRAINT [FK_UserProfileId]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WishList_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WishList]', 'U'))
ALTER TABLE [dbo].[WishList] DROP CONSTRAINT [FK_WishList_Customer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[aspnet_Membership]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Me__Appli__3C34F16F]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Membership]', 'U'))
ALTER TABLE [dbo].[aspnet_Membership] DROP CONSTRAINT [FK__aspnet_Me__Appli__3C34F16F]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Me__UserI__3D2915A8]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Membership]', 'U'))
ALTER TABLE [dbo].[aspnet_Membership] DROP CONSTRAINT [FK__aspnet_Me__UserI__3D2915A8]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[aspnet_Paths]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pa__Appli__6DCC4D03]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Paths]', 'U'))
ALTER TABLE [dbo].[aspnet_Paths] DROP CONSTRAINT [FK__aspnet_Pa__Appli__6DCC4D03]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[aspnet_Roles]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Ro__Appli__5AB9788F]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Roles]', 'U'))
ALTER TABLE [dbo].[aspnet_Roles] DROP CONSTRAINT [FK__aspnet_Ro__Appli__5AB9788F]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[aspnet_Users]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Us__Appli__2BFE89A6]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Users]', 'U'))
ALTER TABLE [dbo].[aspnet_Users] DROP CONSTRAINT [FK__aspnet_Us__Appli__2BFE89A6]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[aspnet_PersonalizationAllUsers]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pe__PathI__73852659]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_PersonalizationAllUsers]', 'U'))
ALTER TABLE [dbo].[aspnet_PersonalizationAllUsers] DROP CONSTRAINT [FK__aspnet_Pe__PathI__73852659]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[aspnet_PersonalizationPerUser]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pe__PathI__7755B73D]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser]', 'U'))
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] DROP CONSTRAINT [FK__aspnet_Pe__PathI__7755B73D]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pe__UserI__7849DB76]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser]', 'U'))
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] DROP CONSTRAINT [FK__aspnet_Pe__UserI__7849DB76]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[aspnet_UsersInRoles]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Us__RoleI__5F7E2DAC]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_UsersInRoles]', 'U'))
ALTER TABLE [dbo].[aspnet_UsersInRoles] DROP CONSTRAINT [FK__aspnet_Us__RoleI__5F7E2DAC]
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Us__UserI__5E8A0973]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_UsersInRoles]', 'U'))
ALTER TABLE [dbo].[aspnet_UsersInRoles] DROP CONSTRAINT [FK__aspnet_Us__UserI__5E8A0973]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping foreign keys from [dbo].[aspnet_Profile]'
GO
IF EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pr__UserI__51300E55]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Profile]', 'U'))
ALTER TABLE [dbo].[aspnet_Profile] DROP CONSTRAINT [FK__aspnet_Pr__UserI__51300E55]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationSetting]'
GO
IF EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_ApplicationSetting_Name]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[ApplicationSetting]', 'U'))
ALTER TABLE [dbo].[ApplicationSetting] DROP CONSTRAINT [CK_ApplicationSetting_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationSetting]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ApplicationSetting]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ApplicationSetting]', 'U'))
ALTER TABLE [dbo].[ApplicationSetting] DROP CONSTRAINT [PK_ApplicationSetting]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationSetting]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ApplicationSettingId' AND object_id = OBJECT_ID(N'[dbo].[ApplicationSetting]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationSetting_ApplicationSettingId]', 'D'))
ALTER TABLE [dbo].[ApplicationSetting] DROP CONSTRAINT [DF_ApplicationSetting_ApplicationSettingId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationSetting]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Value' AND object_id = OBJECT_ID(N'[dbo].[ApplicationSetting]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationSetting_Value]', 'D'))
ALTER TABLE [dbo].[ApplicationSetting] DROP CONSTRAINT [DF_ApplicationSetting_Value]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationSetting]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[ApplicationSetting]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationSetting_Description]', 'D'))
ALTER TABLE [dbo].[ApplicationSetting] DROP CONSTRAINT [DF_ApplicationSetting_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_FilterSection_Name]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U'))
ALTER TABLE [dbo].[AttributeType] DROP CONSTRAINT [CK_FilterSection_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_FilterSection]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U'))
ALTER TABLE [dbo].[AttributeType] DROP CONSTRAINT [PK_FilterSection]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FilterSectionId' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_FilterSection_FilterSectionId]', 'D'))
ALTER TABLE [dbo].[AttributeType] DROP CONSTRAINT [DF_FilterSection_FilterSectionId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_FilterSection_Name]', 'D'))
ALTER TABLE [dbo].[AttributeType] DROP CONSTRAINT [DF_FilterSection_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_FilterSection_IsActive]', 'D'))
ALTER TABLE [dbo].[AttributeType] DROP CONSTRAINT [DF_FilterSection_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Label' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_FilterSection_Label]', 'D'))
ALTER TABLE [dbo].[AttributeType] DROP CONSTRAINT [DF_FilterSection_Label]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsFilter' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_FilterSection_IsFilter]', 'D'))
ALTER TABLE [dbo].[AttributeType] DROP CONSTRAINT [DF_FilterSection_IsFilter]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsComparable' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_FilterSection_IsComparable]', 'D'))
ALTER TABLE [dbo].[AttributeType] DROP CONSTRAINT [DF_FilterSection_IsComparable]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[City]'
GO
IF EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_City_Name]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[City]', 'U'))
ALTER TABLE [dbo].[City] DROP CONSTRAINT [CK_City_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[City]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_City]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[City]', 'U'))
ALTER TABLE [dbo].[City] DROP CONSTRAINT [PK_City]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[City]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CityId' AND object_id = OBJECT_ID(N'[dbo].[City]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_City_CityId]', 'D'))
ALTER TABLE [dbo].[City] DROP CONSTRAINT [DF_City_CityId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[City]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CityName' AND object_id = OBJECT_ID(N'[dbo].[City]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_City_CityName]', 'D'))
ALTER TABLE [dbo].[City] DROP CONSTRAINT [DF_City_CityName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[County]'
GO
IF EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_County_Name]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[County]', 'U'))
ALTER TABLE [dbo].[County] DROP CONSTRAINT [CK_County_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[County]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_County]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[County]', 'U'))
ALTER TABLE [dbo].[County] DROP CONSTRAINT [PK_County]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[County]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CountyId' AND object_id = OBJECT_ID(N'[dbo].[County]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_County_CountyId]', 'D'))
ALTER TABLE [dbo].[County] DROP CONSTRAINT [DF_County_CountyId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[County]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'StateId' AND object_id = OBJECT_ID(N'[dbo].[County]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_County_StateId]', 'D'))
ALTER TABLE [dbo].[County] DROP CONSTRAINT [DF_County_StateId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[County]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[County]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_County_Name]', 'D'))
ALTER TABLE [dbo].[County] DROP CONSTRAINT [DF_County_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[LocalTaxRate]'
GO
IF EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_LocalTaxRate_Zip]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[LocalTaxRate]', 'U'))
ALTER TABLE [dbo].[LocalTaxRate] DROP CONSTRAINT [CK_LocalTaxRate_Zip]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[LocalTaxRate]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_LocalTaxRate]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[LocalTaxRate]', 'U'))
ALTER TABLE [dbo].[LocalTaxRate] DROP CONSTRAINT [PK_LocalTaxRate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[LocalTaxRate]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TaxFreight' AND object_id = OBJECT_ID(N'[dbo].[LocalTaxRate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_LocalTaxRate_TaxFreight]', 'D'))
ALTER TABLE [dbo].[LocalTaxRate] DROP CONSTRAINT [DF_LocalTaxRate_TaxFreight]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PaymentMethod]'
GO
IF EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_PaymentTerm_TermsCode]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U'))
ALTER TABLE [dbo].[PaymentMethod] DROP CONSTRAINT [CK_PaymentTerm_TermsCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PaymentMethod]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PaymentTerm]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U'))
ALTER TABLE [dbo].[PaymentMethod] DROP CONSTRAINT [PK_PaymentTerm]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PaymentMethod]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PaymentTerm_Active]', 'D'))
ALTER TABLE [dbo].[PaymentMethod] DROP CONSTRAINT [DF_PaymentTerm_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PaymentMethod]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PaymentTermId' AND object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PaymentTerm_PaymentTermId]', 'D'))
ALTER TABLE [dbo].[PaymentMethod] DROP CONSTRAINT [DF_PaymentTerm_PaymentTermId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PaymentMethod]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TermsCode' AND object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PaymentTerm_TermsCode]', 'D'))
ALTER TABLE [dbo].[PaymentMethod] DROP CONSTRAINT [DF_PaymentTerm_TermsCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PaymentMethod]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PaymentTerm_Description]', 'D'))
ALTER TABLE [dbo].[PaymentMethod] DROP CONSTRAINT [DF_PaymentTerm_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PaymentMethod]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsCreditCard' AND object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PaymentTerm_IsCreditCard]', 'D'))
ALTER TABLE [dbo].[PaymentMethod] DROP CONSTRAINT [DF_PaymentTerm_IsCreditCard]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_Salesman_SalesmanNumber]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [CK_Salesman_SalesmanNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Salesman]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [PK_Salesman]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalesmanId' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_SalesmanId]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_SalesmanId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalesmanNumber' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_SalesmanNumber]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_SalesmanNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_Salesman]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_Salesman]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalesClass' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_SalesClass]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_SalesClass]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Code' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_Code]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_Code]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalesManager' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_SalesManager]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_SalesManager]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ReferenceNumber' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_ReferenceNumber]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_ReferenceNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Outside' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_Outside]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_Outside]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalesPeriodToDate' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_SalesPeriodToDate]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_SalesPeriodToDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalesYearToDate' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_SalesYearToDate]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_SalesYearToDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Email' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_Email]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_Email]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Phone1' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_Phone1]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_Phone1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Phone2' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_Phone2]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_Phone2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Title' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_Title]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_Title]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ImagePath' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_ImagePath]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_ImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_Description]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MinMarginAllowed' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_MinMarginAllowed]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_MinMarginAllowed]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MaxDiscountPercent' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesman_MaxDiscountPercent]', 'D'))
ALTER TABLE [dbo].[Salesperson] DROP CONSTRAINT [DF_Salesman_MaxDiscountPercent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WishList]'
GO
IF EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_WishList_Name]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[WishList]', 'U'))
ALTER TABLE [dbo].[WishList] DROP CONSTRAINT [CK_WishList_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WishList]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK__WishList__4A43E4FB]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[WishList]', 'U'))
ALTER TABLE [dbo].[WishList] DROP CONSTRAINT [PK__WishList__4A43E4FB]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WishList]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[WishList]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WishList_Name]', 'D'))
ALTER TABLE [dbo].[WishList] DROP CONSTRAINT [DF_WishList_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Affiliate]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Affiliate]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U'))
ALTER TABLE [dbo].[Affiliate] DROP CONSTRAINT [PK_Affiliate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Affiliate]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AffiliateId' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_AffiliateId]', 'D'))
ALTER TABLE [dbo].[Affiliate] DROP CONSTRAINT [DF_Affiliate_AffiliateId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Affiliate]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Image' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_Image]', 'D'))
ALTER TABLE [dbo].[Affiliate] DROP CONSTRAINT [DF_Affiliate_Image]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Affiliate]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_Active]', 'D'))
ALTER TABLE [dbo].[Affiliate] DROP CONSTRAINT [DF_Affiliate_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Affiliate]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_Description]', 'D'))
ALTER TABLE [dbo].[Affiliate] DROP CONSTRAINT [DF_Affiliate_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Affiliate]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Url' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_SiteUrl]', 'D'))
ALTER TABLE [dbo].[Affiliate] DROP CONSTRAINT [DF_Affiliate_SiteUrl]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Affiliate]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ReplaceLogoImage' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_ReplaceLogoImage]', 'D'))
ALTER TABLE [dbo].[Affiliate] DROP CONSTRAINT [DF_Affiliate_ReplaceLogoImage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationDictionary]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ApplicationDictionary]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]', 'U'))
ALTER TABLE [dbo].[ApplicationDictionary] DROP CONSTRAINT [PK_ApplicationDictionary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationDictionary]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ApplicationDictionaryId' AND object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationDictionary_ApplicationDictionaryId]', 'D'))
ALTER TABLE [dbo].[ApplicationDictionary] DROP CONSTRAINT [DF_ApplicationDictionary_ApplicationDictionaryId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationDictionary]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IncludeInExport' AND object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationDictionary_IncludeInExport]', 'D'))
ALTER TABLE [dbo].[ApplicationDictionary] DROP CONSTRAINT [DF_ApplicationDictionary_IncludeInExport]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationDictionary]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ExportWithChildren' AND object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationDictionary_ExportWithChildren]', 'D'))
ALTER TABLE [dbo].[ApplicationDictionary] DROP CONSTRAINT [DF_ApplicationDictionary_ExportWithChildren]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationDictionary]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CanBeLocalized' AND object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationDictionary_CanBeLocalized]', 'D'))
ALTER TABLE [dbo].[ApplicationDictionary] DROP CONSTRAINT [DF_ApplicationDictionary_CanBeLocalized]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationLog]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ApplicationLog]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ApplicationLog]', 'U'))
ALTER TABLE [dbo].[ApplicationLog] DROP CONSTRAINT [PK_ApplicationLog]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationLog]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LogDate' AND object_id = OBJECT_ID(N'[dbo].[ApplicationLog]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationLog_LogDate]', 'D'))
ALTER TABLE [dbo].[ApplicationLog] DROP CONSTRAINT [DF_ApplicationLog_LogDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ApplicationMessage]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Message]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ApplicationMessage]', 'U'))
ALTER TABLE [dbo].[ApplicationMessage] DROP CONSTRAINT [PK_Message]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeValue]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_FilterValue]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[AttributeValue]', 'U'))
ALTER TABLE [dbo].[AttributeValue] DROP CONSTRAINT [PK_FilterValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeValue]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FilterValueId' AND object_id = OBJECT_ID(N'[dbo].[AttributeValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_FilterValue_FilterValueId]', 'D'))
ALTER TABLE [dbo].[AttributeValue] DROP CONSTRAINT [DF_FilterValue_FilterValueId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeValue]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Value' AND object_id = OBJECT_ID(N'[dbo].[AttributeValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_FilterValue_Value]', 'D'))
ALTER TABLE [dbo].[AttributeValue] DROP CONSTRAINT [DF_FilterValue_Value]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeValue]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SortOrder' AND object_id = OBJECT_ID(N'[dbo].[AttributeValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_FilterValue_SortOrder]', 'D'))
ALTER TABLE [dbo].[AttributeValue] DROP CONSTRAINT [DF_FilterValue_SortOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[AttributeValue]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[AttributeValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_FilterValue_IsActive]', 'D'))
ALTER TABLE [dbo].[AttributeValue] DROP CONSTRAINT [DF_FilterValue_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Audit]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Audit]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Audit]', 'U'))
ALTER TABLE [dbo].[Audit] DROP CONSTRAINT [PK_Audit]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[BudgetCalendar]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_BudgetCalendar]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[BudgetCalendar]', 'U'))
ALTER TABLE [dbo].[BudgetCalendar] DROP CONSTRAINT [PK_BudgetCalendar]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CarrierPackage]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CarrierPackage]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierPackage]', 'U'))
ALTER TABLE [dbo].[CarrierPackage] DROP CONSTRAINT [PK_CarrierPackage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CarrierPackage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[CarrierPackage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CarrierPackage_IsActive]', 'D'))
ALTER TABLE [dbo].[CarrierPackage] DROP CONSTRAINT [DF_CarrierPackage_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CarrierZonePostalCodeRange]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CarrierZoneZipCodeRange]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierZonePostalCodeRange]', 'U'))
ALTER TABLE [dbo].[CarrierZonePostalCodeRange] DROP CONSTRAINT [PK_CarrierZoneZipCodeRange]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CarrierZonePostalCodeRange]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CarrierZoneZipCodeRangeId' AND object_id = OBJECT_ID(N'[dbo].[CarrierZonePostalCodeRange]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CarrierZoneZipCodeRange_CarrierZoneZipCodeRangeId]', 'D'))
ALTER TABLE [dbo].[CarrierZonePostalCodeRange] DROP CONSTRAINT [DF_CarrierZoneZipCodeRange_CarrierZoneZipCodeRangeId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CarrierZonePostalCodeRange]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ZipStartRange' AND object_id = OBJECT_ID(N'[dbo].[CarrierZonePostalCodeRange]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CarrierZoneZipCodeRange_ZipStartRange]', 'D'))
ALTER TABLE [dbo].[CarrierZonePostalCodeRange] DROP CONSTRAINT [DF_CarrierZoneZipCodeRange_ZipStartRange]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CarrierZonePostalCodeRange]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ZipEndRange' AND object_id = OBJECT_ID(N'[dbo].[CarrierZonePostalCodeRange]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CarrierZoneZipCodeRange_ZipEndRange]', 'D'))
ALTER TABLE [dbo].[CarrierZonePostalCodeRange] DROP CONSTRAINT [DF_CarrierZoneZipCodeRange_ZipEndRange]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CarrierZoneRate]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CarrierZoneRate]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierZoneRate]', 'U'))
ALTER TABLE [dbo].[CarrierZoneRate] DROP CONSTRAINT [PK_CarrierZoneRate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CarrierZone]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CarrierZone]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierZone]', 'U'))
ALTER TABLE [dbo].[CarrierZone] DROP CONSTRAINT [PK_CarrierZone]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Carrier]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Carrier]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U'))
ALTER TABLE [dbo].[Carrier] DROP CONSTRAINT [PK_Carrier]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Carrier]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_Description]', 'D'))
ALTER TABLE [dbo].[Carrier] DROP CONSTRAINT [DF_Carrier_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Carrier]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Image' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_Image]', 'D'))
ALTER TABLE [dbo].[Carrier] DROP CONSTRAINT [DF_Carrier_Image]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Carrier]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AccessKey' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_AccessKey]', 'D'))
ALTER TABLE [dbo].[Carrier] DROP CONSTRAINT [DF_Carrier_AccessKey]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Carrier]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Enable' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_Enable]', 'D'))
ALTER TABLE [dbo].[Carrier] DROP CONSTRAINT [DF_Carrier_Enable]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Carrier]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsLive' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_IsLive]', 'D'))
ALTER TABLE [dbo].[Carrier] DROP CONSTRAINT [DF_Carrier_IsLive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Carrier]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LiveUrl' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_LiveUrl]', 'D'))
ALTER TABLE [dbo].[Carrier] DROP CONSTRAINT [DF_Carrier_LiveUrl]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Carrier]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TestUrl' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_TestUrl]', 'D'))
ALTER TABLE [dbo].[Carrier] DROP CONSTRAINT [DF_Carrier_TestUrl]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Carrier]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPrimaryCarrier' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_IsPrimaryCarrier]', 'D'))
ALTER TABLE [dbo].[Carrier] DROP CONSTRAINT [DF_Carrier_IsPrimaryCarrier]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CategoryAttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CategoryFilterSection_1]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U'))
ALTER TABLE [dbo].[CategoryAttributeType] DROP CONSTRAINT [PK_CategoryFilterSection_1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CategoryAttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CategoryFilterSectionId' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CategoryFilterSection_CategoryFilterSectionId]', 'D'))
ALTER TABLE [dbo].[CategoryAttributeType] DROP CONSTRAINT [DF_CategoryFilterSection_CategoryFilterSectionId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CategoryAttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SortOrder' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CategoryFilterSection_SortOrder]', 'D'))
ALTER TABLE [dbo].[CategoryAttributeType] DROP CONSTRAINT [DF_CategoryFilterSection_SortOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CategoryAttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CategoryFilterSection_IsActive]', 'D'))
ALTER TABLE [dbo].[CategoryAttributeType] DROP CONSTRAINT [DF_CategoryFilterSection_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CategoryAttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DetailDisplaySequence' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CategoryFilterSection_DetailDisplaySequence]', 'D'))
ALTER TABLE [dbo].[CategoryAttributeType] DROP CONSTRAINT [DF_CategoryFilterSection_DetailDisplaySequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CategoryAttributeValue]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CategoryFilterValue]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryAttributeValue]', 'U'))
ALTER TABLE [dbo].[CategoryAttributeValue] DROP CONSTRAINT [PK_CategoryFilterValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CategoryProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CategoryProduct]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProduct]', 'U'))
ALTER TABLE [dbo].[CategoryProduct] DROP CONSTRAINT [PK_CategoryProduct]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CategoryProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CategoryProperty_1]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProperty]', 'U'))
ALTER TABLE [dbo].[CategoryProperty] DROP CONSTRAINT [PK_CategoryProperty_1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Category]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Category]', 'U'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [PK_Category]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_Description]', 'D'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [DF_Category_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'StyleSheet' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_StyleSheet]', 'D'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [DF_Category_StyleSheet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SmallImagePath' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_SmallImagePath]', 'D'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [DF_Category_SmallImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LargeImagePath' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_LargeImagePath]', 'D'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [DF_Category_LargeImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_Active]', 'D'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [DF_Category_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PageTitle' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_PageTitle]', 'D'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [DF_Category_PageTitle]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsFeatured' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_IsFeatured]', 'D'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [DF_Category_IsFeatured]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDynamic' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_IsDynamic]', 'D'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [DF_Category_IsDynamic]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltText' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_AltText]', 'D'))
ALTER TABLE [dbo].[Category] DROP CONSTRAINT [DF_Category_AltText]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Company]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Company]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Company]', 'U'))
ALTER TABLE [dbo].[Company] DROP CONSTRAINT [PK_Company]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Company]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LeftNavigation' AND object_id = OBJECT_ID(N'[dbo].[Company]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Company_LeftNavigation]', 'D'))
ALTER TABLE [dbo].[Company] DROP CONSTRAINT [DF_Company_LeftNavigation]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Company]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BottomNavigation' AND object_id = OBJECT_ID(N'[dbo].[Company]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Company_BottomNavigation]', 'D'))
ALTER TABLE [dbo].[Company] DROP CONSTRAINT [DF_Company_BottomNavigation]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Company]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RightNavigation' AND object_id = OBJECT_ID(N'[dbo].[Company]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Company_RightNavigation]', 'D'))
ALTER TABLE [dbo].[Company] DROP CONSTRAINT [DF_Company_RightNavigation]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Company]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TopNavigation' AND object_id = OBJECT_ID(N'[dbo].[Company]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Company_TopNavigation]', 'D'))
ALTER TABLE [dbo].[Company] DROP CONSTRAINT [DF_Company_TopNavigation]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Company]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Image' AND object_id = OBJECT_ID(N'[dbo].[Company]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Company_Image]', 'D'))
ALTER TABLE [dbo].[Company] DROP CONSTRAINT [DF_Company_Image]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Company]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ReplaceLogoImage' AND object_id = OBJECT_ID(N'[dbo].[Company]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Company_ReplaceImage]', 'D'))
ALTER TABLE [dbo].[Company] DROP CONSTRAINT [DF_Company_ReplaceImage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationConditionFilter]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ConfigurationConditionFilter]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationConditionFilter]', 'U'))
ALTER TABLE [dbo].[ConfigurationConditionFilter] DROP CONSTRAINT [PK_ConfigurationConditionFilter]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationOptionCondition]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ConfigurationOptionCondition]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationOptionCondition]', 'U'))
ALTER TABLE [dbo].[ConfigurationOptionCondition] DROP CONSTRAINT [PK_ConfigurationOptionCondition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationOptionCondition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Sequence' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOptionCondition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOptionCondition_Sequence]', 'D'))
ALTER TABLE [dbo].[ConfigurationOptionCondition] DROP CONSTRAINT [DF_ConfigurationOptionCondition_Sequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationOptionCondition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QueryName' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOptionCondition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOptionCondition_QueryName]', 'D'))
ALTER TABLE [dbo].[ConfigurationOptionCondition] DROP CONSTRAINT [DF_ConfigurationOptionCondition_QueryName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationOption]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ConfigurationOption]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U'))
ALTER TABLE [dbo].[ConfigurationOption] DROP CONSTRAINT [PK_ConfigurationOption]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationPage]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ConfigurationPage]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U'))
ALTER TABLE [dbo].[ConfigurationPage] DROP CONSTRAINT [PK_ConfigurationPage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationPage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SkipIfNoInputs' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationPage_SkipIfNoInputs]', 'D'))
ALTER TABLE [dbo].[ConfigurationPage] DROP CONSTRAINT [DF_ConfigurationPage_SkipIfNoInputs]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationPage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SkipScriptsIfNoInputs' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationPage_SkipScriptsIfNoInputs]', 'D'))
ALTER TABLE [dbo].[ConfigurationPage] DROP CONSTRAINT [DF_ConfigurationPage_SkipScriptsIfNoInputs]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationPage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OverrideHtmlOutput' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationPage_OverrideHtmlOutput]', 'D'))
ALTER TABLE [dbo].[ConfigurationPage] DROP CONSTRAINT [DF_ConfigurationPage_OverrideHtmlOutput]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationPage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OverrideCssOutput' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationPage_OverrideCssOutput]', 'D'))
ALTER TABLE [dbo].[ConfigurationPage] DROP CONSTRAINT [DF_ConfigurationPage_OverrideCssOutput]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationPage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OverrideJavaScriptOutput' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationPage_OverrideJavaScriptOutput]', 'D'))
ALTER TABLE [dbo].[ConfigurationPage] DROP CONSTRAINT [DF_ConfigurationPage_OverrideJavaScriptOutput]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationQueryResultField]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ConfigurationQueryResultField]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationQueryResultField]', 'U'))
ALTER TABLE [dbo].[ConfigurationQueryResultField] DROP CONSTRAINT [PK_ConfigurationQueryResultField]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationQueryResultValue]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ConfigurationQueryResultValue]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationQueryResultValue]', 'U'))
ALTER TABLE [dbo].[ConfigurationQueryResultValue] DROP CONSTRAINT [PK_ConfigurationQueryResultValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ConfigurationQueryResult]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ConfigurationQueryResults]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationQueryResult]', 'U'))
ALTER TABLE [dbo].[ConfigurationQueryResult] DROP CONSTRAINT [PK_ConfigurationQueryResults]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Configuration]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Configuration]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Configuration]', 'U'))
ALTER TABLE [dbo].[Configuration] DROP CONSTRAINT [PK_Configuration]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Configuration]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HasSmartPart' AND object_id = OBJECT_ID(N'[dbo].[Configuration]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationHeader_HasSmartPart]', 'D'))
ALTER TABLE [dbo].[Configuration] DROP CONSTRAINT [DF_ConfigurationHeader_HasSmartPart]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Configuration]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OverrideOnRefresh' AND object_id = OBJECT_ID(N'[dbo].[Configuration]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationHeader_OverrideOnRefresh]', 'D'))
ALTER TABLE [dbo].[Configuration] DROP CONSTRAINT [DF_ConfigurationHeader_OverrideOnRefresh]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Configuration]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DisplaySummary' AND object_id = OBJECT_ID(N'[dbo].[Configuration]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationHeader_DisplaySummary]', 'D'))
ALTER TABLE [dbo].[Configuration] DROP CONSTRAINT [DF_ConfigurationHeader_DisplaySummary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ContentItemField]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ContentItemField]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U'))
ALTER TABLE [dbo].[ContentItemField] DROP CONSTRAINT [PK_ContentItemField]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ContentItemField]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ContentItemFieldId' AND object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentItemField_ContentItemFieldId]', 'D'))
ALTER TABLE [dbo].[ContentItemField] DROP CONSTRAINT [DF_ContentItemField_ContentItemFieldId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ContentItemField]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentItemField_CreatedOn]', 'D'))
ALTER TABLE [dbo].[ContentItemField] DROP CONSTRAINT [DF_ContentItemField_CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ContentItem]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ContentItem]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U'))
ALTER TABLE [dbo].[ContentItem] DROP CONSTRAINT [PK_ContentItem]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ContentItem]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ContentItemId' AND object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentItem_ContentItemId]', 'D'))
ALTER TABLE [dbo].[ContentItem] DROP CONSTRAINT [DF_ContentItem_ContentItemId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ContentItem]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPage' AND object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentItem_IsPage]', 'D'))
ALTER TABLE [dbo].[ContentItem] DROP CONSTRAINT [DF_ContentItem_IsPage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ContentItem]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentItem_CreatedOn]', 'D'))
ALTER TABLE [dbo].[ContentItem] DROP CONSTRAINT [DF_ContentItem_CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ContentManager]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ContentManager]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentManager]', 'U'))
ALTER TABLE [dbo].[ContentManager] DROP CONSTRAINT [PK_ContentManager]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ContentPageState]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ContentPageState]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentPageState]', 'U'))
ALTER TABLE [dbo].[ContentPageState] DROP CONSTRAINT [PK_ContentPageState]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ContentPageState]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ContentPageStateId' AND object_id = OBJECT_ID(N'[dbo].[ContentPageState]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentPageState_ContentPageStateId]', 'D'))
ALTER TABLE [dbo].[ContentPageState] DROP CONSTRAINT [DF_ContentPageState_ContentPageStateId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Content]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Content]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Content]', 'U'))
ALTER TABLE [dbo].[Content] DROP CONSTRAINT [PK_Content]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Content]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Created' AND object_id = OBJECT_ID(N'[dbo].[Content]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Content_Created]', 'D'))
ALTER TABLE [dbo].[Content] DROP CONSTRAINT [DF_Content_Created]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Content]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[Content]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Content_LanguageCode]', 'D'))
ALTER TABLE [dbo].[Content] DROP CONSTRAINT [DF_Content_LanguageCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Country]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Country]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Country]', 'U'))
ALTER TABLE [dbo].[Country] DROP CONSTRAINT [PK_Country]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Country]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Country]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Country_IsActive]', 'D'))
ALTER TABLE [dbo].[Country] DROP CONSTRAINT [DF_Country_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CreditCardTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CreditCardTransaction]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]', 'U'))
ALTER TABLE [dbo].[CreditCardTransaction] DROP CONSTRAINT [PK_CreditCardTransaction]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CreditCardTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount' AND object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CreditCardTransaction_Amount]', 'D'))
ALTER TABLE [dbo].[CreditCardTransaction] DROP CONSTRAINT [DF_CreditCardTransaction_Amount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CreditCardTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PostedToERP' AND object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CreditCardTransaction_PostedToERP]', 'D'))
ALTER TABLE [dbo].[CreditCardTransaction] DROP CONSTRAINT [DF_CreditCardTransaction_PostedToERP]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CurrencyRate]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CurrencyRate]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CurrencyRate]', 'U'))
ALTER TABLE [dbo].[CurrencyRate] DROP CONSTRAINT [PK_CurrencyRate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CurrencyRate]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'EffectiveDate' AND object_id = OBJECT_ID(N'[dbo].[CurrencyRate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CurrencyRate_EffectiveDate]', 'D'))
ALTER TABLE [dbo].[CurrencyRate] DROP CONSTRAINT [DF_CurrencyRate_EffectiveDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Currency]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Currency]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Currency]', 'U'))
ALTER TABLE [dbo].[Currency] DROP CONSTRAINT [PK_Currency]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Currency]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[Currency]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Currency_IsDefault]', 'D'))
ALTER TABLE [dbo].[Currency] DROP CONSTRAINT [DF_Currency_IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CustomProperty]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomProperty]', 'U'))
ALTER TABLE [dbo].[CustomProperty] DROP CONSTRAINT [PK_CustomProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerBudget]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CustomerBudget]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerBudget]', 'U'))
ALTER TABLE [dbo].[CustomerBudget] DROP CONSTRAINT [PK_CustomerBudget]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerCostCode]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CustomerCostCode]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerCostCode]', 'U'))
ALTER TABLE [dbo].[CustomerCostCode] DROP CONSTRAINT [PK_CustomerCostCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerCostCode]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[CustomerCostCode]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerCostCode_IsActive]', 'D'))
ALTER TABLE [dbo].[CustomerCostCode] DROP CONSTRAINT [DF_CustomerCostCode_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerDiscount]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CustomerDiscount]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerDiscount]', 'U'))
ALTER TABLE [dbo].[CustomerDiscount] DROP CONSTRAINT [PK_CustomerDiscount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerDiscount]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerDiscountId' AND object_id = OBJECT_ID(N'[dbo].[CustomerDiscount]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerDiscount_CustomerDiscountId]', 'D'))
ALTER TABLE [dbo].[CustomerDiscount] DROP CONSTRAINT [DF_CustomerDiscount_CustomerDiscountId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerDiscount]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerId' AND object_id = OBJECT_ID(N'[dbo].[CustomerDiscount]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerDiscount_CustomerId]', 'D'))
ALTER TABLE [dbo].[CustomerDiscount] DROP CONSTRAINT [DF_CustomerDiscount_CustomerId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerDiscount]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'WebSiteId' AND object_id = OBJECT_ID(N'[dbo].[CustomerDiscount]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerDiscount_WebSiteId]', 'D'))
ALTER TABLE [dbo].[CustomerDiscount] DROP CONSTRAINT [DF_CustomerDiscount_WebSiteId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerDiscount]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Discount' AND object_id = OBJECT_ID(N'[dbo].[CustomerDiscount]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerDiscount_Discount]', 'D'))
ALTER TABLE [dbo].[CustomerDiscount] DROP CONSTRAINT [DF_CustomerDiscount_Discount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerDiscount]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ApplyDiscount' AND object_id = OBJECT_ID(N'[dbo].[CustomerDiscount]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerDiscount_ApplyDiscount]', 'D'))
ALTER TABLE [dbo].[CustomerDiscount] DROP CONSTRAINT [DF_CustomerDiscount_ApplyDiscount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerDiscount]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[CustomerDiscount]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerDiscount_Name]', 'D'))
ALTER TABLE [dbo].[CustomerDiscount] DROP CONSTRAINT [DF_CustomerDiscount_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerDiscount]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[CustomerDiscount]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerDiscount_Description]', 'D'))
ALTER TABLE [dbo].[CustomerDiscount] DROP CONSTRAINT [DF_CustomerDiscount_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrderProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CustomerOrderProperty]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrderProperty]', 'U'))
ALTER TABLE [dbo].[CustomerOrderProperty] DROP CONSTRAINT [PK_CustomerOrderProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Order]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [PK_Order]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerPOTypeCode' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_CustomerPOTypeCode]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_CustomerPOTypeCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceCode' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_PriceCode]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_PriceCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CurrencyCode' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_CurrencyCode]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_CurrencyCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'EndUserType' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_EndUserType]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_EndUserType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Salesman' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_Salesman]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_Salesman]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceFrequency' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_InvoiceFrequency]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_InvoiceFrequency]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BTContact1' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_BTContact1]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_BTContact1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BTContact2' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_BTContact2]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_BTContact2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BTContact3' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_BTContact3]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_BTContact3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BTPhone2' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_BTPhone2]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_BTPhone2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BTPhone3' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_BTPhone3]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_BTPhone3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BTFax' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_BTFax]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_BTFax]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BTCounty' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_BTCounty]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_BTCounty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'STContact1' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_STContact1]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_STContact1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'STContact2' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_STContact2]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_STContact2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'STContact3' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_STContact3]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_STContact3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'STPhone2' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_STPhone2]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_STPhone2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'STPhone3' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_STPhone3]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_STPhone3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'STFax' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_STFax]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_STFax]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'STCounty' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_STCounty]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_STCounty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LiftGateService' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_LiftGateService]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_LiftGateService]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OrderDate' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Order_OrderDate]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_Order_OrderDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_LanguageCode]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_LanguageCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipEarly' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_ShipEarly]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_ShipEarly]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipPartial' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_ShipPartial]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_ShipPartial]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Residential' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_Residential]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_Residential]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InsideDelivery' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_InsideDelivery]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_InsideDelivery]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ConversionRate' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_ConversionRate]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] DROP CONSTRAINT [DF_CustomerOrder_ConversionRate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CustomerProductPrice]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U'))
ALTER TABLE [dbo].[CustomerProductPrice] DROP CONSTRAINT [PK_CustomerProductPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerProductPriceId' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerProductPrice_CustomerProductPriceId]', 'D'))
ALTER TABLE [dbo].[CustomerProductPrice] DROP CONSTRAINT [DF_CustomerProductPrice_CustomerProductPriceId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerProductPrice_BreakQty]', 'D'))
ALTER TABLE [dbo].[CustomerProductPrice] DROP CONSTRAINT [DF_CustomerProductPrice_BreakQty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerProductPrice_Active]', 'D'))
ALTER TABLE [dbo].[CustomerProductPrice] DROP CONSTRAINT [DF_CustomerProductPrice_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PricePerPiece' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerProductPrice_PricePerPiece]', 'D'))
ALTER TABLE [dbo].[CustomerProductPrice] DROP CONSTRAINT [DF_CustomerProductPrice_PricePerPiece]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsOnSale' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerProductPrice_IsOnSale]', 'D'))
ALTER TABLE [dbo].[CustomerProductPrice] DROP CONSTRAINT [DF_CustomerProductPrice_IsOnSale]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RegularMarkup' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerProductPrice_RegularMarkup]', 'D'))
ALTER TABLE [dbo].[CustomerProductPrice] DROP CONSTRAINT [DF_CustomerProductPrice_RegularMarkup]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SaleMarkup' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerProductPrice_SaleMarkup]', 'D'))
ALTER TABLE [dbo].[CustomerProductPrice] DROP CONSTRAINT [DF_CustomerProductPrice_SaleMarkup]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CurrencyCode' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerProductPrice_CurrencyCode]', 'D'))
ALTER TABLE [dbo].[CustomerProductPrice] DROP CONSTRAINT [DF_CustomerProductPrice_CurrencyCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductSetProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK__CustomerProductS__3BB5CE82]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProductSetProduct]', 'U'))
ALTER TABLE [dbo].[CustomerProductSetProduct] DROP CONSTRAINT [PK__CustomerProductS__3BB5CE82]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductSet]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK__CustomerProductS__3508D0F3]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]', 'U'))
ALTER TABLE [dbo].[CustomerProductSet] DROP CONSTRAINT [PK__CustomerProductS__3508D0F3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductSet]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerProductSet_Name]', 'D'))
ALTER TABLE [dbo].[CustomerProductSet] DROP CONSTRAINT [DF_CustomerProductSet_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductSet]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerProductSet_Description]', 'D'))
ALTER TABLE [dbo].[CustomerProductSet] DROP CONSTRAINT [DF_CustomerProductSet_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProductSet]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerProductSet_Active]', 'D'))
ALTER TABLE [dbo].[CustomerProductSet] DROP CONSTRAINT [DF_CustomerProductSet_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CustomerProduct]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProduct]', 'U'))
ALTER TABLE [dbo].[CustomerProduct] DROP CONSTRAINT [PK_CustomerProduct]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CustomerProperty]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProperty]', 'U'))
ALTER TABLE [dbo].[CustomerProperty] DROP CONSTRAINT [PK_CustomerProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerSalesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_CustomerSalesman]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerSalesperson]', 'U'))
ALTER TABLE [dbo].[CustomerSalesperson] DROP CONSTRAINT [PK_CustomerSalesman]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerSalesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerId' AND object_id = OBJECT_ID(N'[dbo].[CustomerSalesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerSalesman_CustomerId]', 'D'))
ALTER TABLE [dbo].[CustomerSalesperson] DROP CONSTRAINT [DF_CustomerSalesman_CustomerId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerSalesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalesmanId' AND object_id = OBJECT_ID(N'[dbo].[CustomerSalesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerSalesman_SalesmanId]', 'D'))
ALTER TABLE [dbo].[CustomerSalesperson] DROP CONSTRAINT [DF_CustomerSalesman_SalesmanId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerUserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK__CustomerUserProf__2F4FF79D]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerUserProfile]', 'U'))
ALTER TABLE [dbo].[CustomerUserProfile] DROP CONSTRAINT [PK__CustomerUserProf__2F4FF79D]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerUserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CustomerUserProfile_uq]', 'UQ') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerUserProfile]', 'U'))
ALTER TABLE [dbo].[CustomerUserProfile] DROP CONSTRAINT [CustomerUserProfile_uq]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[CustomerUserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[CustomerUserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerUserProfile_IsDefault]', 'D'))
ALTER TABLE [dbo].[CustomerUserProfile] DROP CONSTRAINT [DF_CustomerUserProfile_IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Customer]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [PK_Customer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Contact2' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_Contact2]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_Contact2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Contact3' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_Contact3]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_Contact3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Phone2' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_Phone2]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_Phone2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Phone3' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_Phone3]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_Phone3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Salesman' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_Salesman]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_Salesman]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceFrequency' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_InvoiceFrequency]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_InvoiceFrequency]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'County' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_County]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_County]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TermsOfUse' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_TermsOfUse]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_TermsOfUse]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerReferenceLabel1' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_CustomerReferenceLabel1]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_CustomerReferenceLabel1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerReferenceLabel2' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_CustomerReferenceLabel2]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_CustomerReferenceLabel2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SendFax' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_SendFax]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_SendFax]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Directory' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_Directory]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_Directory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OpenInvoiceAmount' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_OpenInvoiceAmount]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_OpenInvoiceAmount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OpenOrderAmount' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_OpenOrderAmount]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_OpenOrderAmount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AgingBucket1' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_AgingBucket1]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_AgingBucket1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AgingBucket2' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_AgingBucket2]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_AgingBucket2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AgingBucket3' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_AgingBucket3]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_AgingBucket3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AgingBucket4' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_AgingBucket4]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_AgingBucket4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AgingBucket5' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_AgingBucket5]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_AgingBucket5]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipEarly' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_ShipEarly]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_ShipEarly]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipPartial' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_ShipPartial]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_ShipPartial]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreditHold' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_CreditHold]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_CreditHold]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreditLimit' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_CreditLimit]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_CreditLimit]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SendEmail' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_SendEmail]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_SendEmail]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Image' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_Image]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_Image]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_Active]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AllowDropShip' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_AllowDropShip]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_AllowDropShip]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DropShipFeeRequired' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_DropShipFeeRequired]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_DropShipFeeRequired]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDropShip' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_IsDropShip]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_IsDropShip]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsGuest' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_IsGuest]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_IsGuest]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomLandingPage' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_CustomLandingPage]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_CustomLandingPage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IgnoreProductRestrictions' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerUserProfile_IgnoreProductRestrictions]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_CustomerUserProfile_IgnoreProductRestrictions]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ModifyDate' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_ModifyDate]', 'D'))
ALTER TABLE [dbo].[Customer] DROP CONSTRAINT [DF_Customer_ModifyDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[DashboardPanelPosition]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_DashboardPanelPosition]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[DashboardPanelPosition]', 'U'))
ALTER TABLE [dbo].[DashboardPanelPosition] DROP CONSTRAINT [PK_DashboardPanelPosition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[DatabaseScript]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_DatabaseScript]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[DatabaseScript]', 'U'))
ALTER TABLE [dbo].[DatabaseScript] DROP CONSTRAINT [PK_DatabaseScript]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[DatabaseScript]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Applied' AND object_id = OBJECT_ID(N'[dbo].[DatabaseScript]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_DatabaseScript_Applied]', 'D'))
ALTER TABLE [dbo].[DatabaseScript] DROP CONSTRAINT [DF_DatabaseScript_Applied]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[DealerProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_DealerProperty]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[DealerProperty]', 'U'))
ALTER TABLE [dbo].[DealerProperty] DROP CONSTRAINT [PK_DealerProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Dealer]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Dealers]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Dealer]', 'U'))
ALTER TABLE [dbo].[Dealer] DROP CONSTRAINT [PK_Dealers]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[DictionaryAttribute]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_DictionaryAttribute]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[DictionaryAttribute]', 'U'))
ALTER TABLE [dbo].[DictionaryAttribute] DROP CONSTRAINT [PK_DictionaryAttribute]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[DictionaryAttribute]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RequiredField' AND object_id = OBJECT_ID(N'[dbo].[DictionaryAttribute]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_DictionaryAttribute_RequiredField]', 'D'))
ALTER TABLE [dbo].[DictionaryAttribute] DROP CONSTRAINT [DF_DictionaryAttribute_RequiredField]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[DictionaryAttribute]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IncludeInGrid' AND object_id = OBJECT_ID(N'[dbo].[DictionaryAttribute]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_DictionaryAttribute_IncludeInGrid]', 'D'))
ALTER TABLE [dbo].[DictionaryAttribute] DROP CONSTRAINT [DF_DictionaryAttribute_IncludeInGrid]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[DictionaryAttribute]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DefaultValue' AND object_id = OBJECT_ID(N'[dbo].[DictionaryAttribute]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_DictionaryAttribute_DefaultValue]', 'D'))
ALTER TABLE [dbo].[DictionaryAttribute] DROP CONSTRAINT [DF_DictionaryAttribute_DefaultValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[DictionaryLabel]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_DictionaryLabel]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[DictionaryLabel]', 'U'))
ALTER TABLE [dbo].[DictionaryLabel] DROP CONSTRAINT [PK_DictionaryLabel]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[DictionaryLabel]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[DictionaryLabel]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_DictionaryLabel_LanguageCode]', 'D'))
ALTER TABLE [dbo].[DictionaryLabel] DROP CONSTRAINT [DF_DictionaryLabel_LanguageCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[DocumentManager]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_DocumentManager]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[DocumentManager]', 'U'))
ALTER TABLE [dbo].[DocumentManager] DROP CONSTRAINT [PK_DocumentManager]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Document]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Document]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Document]', 'U'))
ALTER TABLE [dbo].[Document] DROP CONSTRAINT [PK_Document]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Document]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Document]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Document_Description]', 'D'))
ALTER TABLE [dbo].[Document] DROP CONSTRAINT [DF_Document_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Document]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Created' AND object_id = OBJECT_ID(N'[dbo].[Document]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Document_Created]', 'D'))
ALTER TABLE [dbo].[Document] DROP CONSTRAINT [DF_Document_Created]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Document]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FilePath' AND object_id = OBJECT_ID(N'[dbo].[Document]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Document_FilePath]', 'D'))
ALTER TABLE [dbo].[Document] DROP CONSTRAINT [DF_Document_FilePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Document]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FileName' AND object_id = OBJECT_ID(N'[dbo].[Document]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Document_FileName]', 'D'))
ALTER TABLE [dbo].[Document] DROP CONSTRAINT [DF_Document_FileName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Document]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[Document]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Document_LanguageCode]', 'D'))
ALTER TABLE [dbo].[Document] DROP CONSTRAINT [DF_Document_LanguageCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[EmailList]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_EmailList]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailList]', 'U'))
ALTER TABLE [dbo].[EmailList] DROP CONSTRAINT [PK_EmailList]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[EmailList]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CanSubscribe' AND object_id = OBJECT_ID(N'[dbo].[EmailList]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_EmailList_CanSubscribe]', 'D'))
ALTER TABLE [dbo].[EmailList] DROP CONSTRAINT [DF_EmailList_CanSubscribe]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[EmailMessageAddress]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_EmailMessageAddress]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailMessageAddress]', 'U'))
ALTER TABLE [dbo].[EmailMessageAddress] DROP CONSTRAINT [PK_EmailMessageAddress]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[EmailMessageDeliveryAttempt]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_EmailMessageDeliveryAttempt]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailMessageDeliveryAttempt]', 'U'))
ALTER TABLE [dbo].[EmailMessageDeliveryAttempt] DROP CONSTRAINT [PK_EmailMessageDeliveryAttempt]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[EmailMessageDeliveryAttempt]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AttemptedDateTime' AND object_id = OBJECT_ID(N'[dbo].[EmailMessageDeliveryAttempt]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_EmailMessageDeliveryAttempt_AttemptedDateTime]', 'D'))
ALTER TABLE [dbo].[EmailMessageDeliveryAttempt] DROP CONSTRAINT [DF_EmailMessageDeliveryAttempt_AttemptedDateTime]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[EmailMessage]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_EmailMessage]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailMessage]', 'U'))
ALTER TABLE [dbo].[EmailMessage] DROP CONSTRAINT [PK_EmailMessage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[EmailMessage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SentDate' AND object_id = OBJECT_ID(N'[dbo].[EmailMessage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_EmailMessage_SentDate]', 'D'))
ALTER TABLE [dbo].[EmailMessage] DROP CONSTRAINT [DF_EmailMessage_SentDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[EmailSubscriber]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_EmailSubscriber]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailSubscriber]', 'U'))
ALTER TABLE [dbo].[EmailSubscriber] DROP CONSTRAINT [PK_EmailSubscriber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[EmailSubscriber]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'EmailSubscriberId' AND object_id = OBJECT_ID(N'[dbo].[EmailSubscriber]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_EmailSubscriber_EmailSubscriberId]', 'D'))
ALTER TABLE [dbo].[EmailSubscriber] DROP CONSTRAINT [DF_EmailSubscriber_EmailSubscriberId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[EmailTemplate]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_EmailTemplate]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailTemplate]', 'U'))
ALTER TABLE [dbo].[EmailTemplate] DROP CONSTRAINT [PK_EmailTemplate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[GiftCardTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_GiftCardTransaction]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[GiftCardTransaction]', 'U'))
ALTER TABLE [dbo].[GiftCardTransaction] DROP CONSTRAINT [PK_GiftCardTransaction]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[GiftCardTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TransactionDate' AND object_id = OBJECT_ID(N'[dbo].[GiftCardTransaction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_GiftCardTransaction_TransactionDate]', 'D'))
ALTER TABLE [dbo].[GiftCardTransaction] DROP CONSTRAINT [DF_GiftCardTransaction_TransactionDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[GiftCard]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_GiftCard]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[GiftCard]', 'U'))
ALTER TABLE [dbo].[GiftCard] DROP CONSTRAINT [PK_GiftCard]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[GiftCard]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Purchased' AND object_id = OBJECT_ID(N'[dbo].[GiftCard]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_GiftCard_Purchased]', 'D'))
ALTER TABLE [dbo].[GiftCard] DROP CONSTRAINT [DF_GiftCard_Purchased]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[GiftCard]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[GiftCard]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_GiftCard_Active]', 'D'))
ALTER TABLE [dbo].[GiftCard] DROP CONSTRAINT [DF_GiftCard_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[GlobalSynonym]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_GlobalSynonym]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[GlobalSynonym]', 'U'))
ALTER TABLE [dbo].[GlobalSynonym] DROP CONSTRAINT [PK_GlobalSynonym]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[GlobalSynonym]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[GlobalSynonym]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_GlobalSynonym_LanguageCode]', 'D'))
ALTER TABLE [dbo].[GlobalSynonym] DROP CONSTRAINT [DF_GlobalSynonym_LanguageCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[HtmlRedirect]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_HtmlRedirect]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[HtmlRedirect]', 'U'))
ALTER TABLE [dbo].[HtmlRedirect] DROP CONSTRAINT [PK_HtmlRedirect]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationConnection]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_IntegrationConnection]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationConnection]', 'U'))
ALTER TABLE [dbo].[IntegrationConnection] DROP CONSTRAINT [PK_IntegrationConnection]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationConnection]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DebuggingEnabled' AND object_id = OBJECT_ID(N'[dbo].[IntegrationConnection]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationConnection_DebuggingEnabled]', 'D'))
ALTER TABLE [dbo].[IntegrationConnection] DROP CONSTRAINT [DF_IntegrationConnection_DebuggingEnabled]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationJobLog]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_IntegrationJobLog]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationJobLog]', 'U'))
ALTER TABLE [dbo].[IntegrationJobLog] DROP CONSTRAINT [PK_IntegrationJobLog]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationJobParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_IntegrationJobParameter]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationJobParameter]', 'U'))
ALTER TABLE [dbo].[IntegrationJobParameter] DROP CONSTRAINT [PK_IntegrationJobParameter]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationJobParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Value' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJobParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobParameter_Value]', 'D'))
ALTER TABLE [dbo].[IntegrationJobParameter] DROP CONSTRAINT [DF_IntegrationJobParameter_Value]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_IntegrationJob]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U'))
ALTER TABLE [dbo].[IntegrationJob] DROP CONSTRAINT [PK_IntegrationJob]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJob_CreatedOn]', 'D'))
ALTER TABLE [dbo].[IntegrationJob] DROP CONSTRAINT [DF_IntegrationJob_CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedBy' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJob_CreatedBy]', 'D'))
ALTER TABLE [dbo].[IntegrationJob] DROP CONSTRAINT [DF_IntegrationJob_CreatedBy]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ModifiedOn' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJob_ModifiedOn]', 'D'))
ALTER TABLE [dbo].[IntegrationJob] DROP CONSTRAINT [DF_IntegrationJob_ModifiedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsRealTime' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJob_IsRealTime]', 'D'))
ALTER TABLE [dbo].[IntegrationJob] DROP CONSTRAINT [DF_IntegrationJob_IsRealTime]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPreview' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJob_IsPreview]', 'D'))
ALTER TABLE [dbo].[IntegrationJob] DROP CONSTRAINT [DF_IntegrationJob_IsPreview]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DeltaDataSetProcessed' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJob_DeltaDataSetProcessed]', 'D'))
ALTER TABLE [dbo].[IntegrationJob] DROP CONSTRAINT [DF_IntegrationJob_DeltaDataSetProcessed]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FileProcessed' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJob_FileProcessed]', 'D'))
ALTER TABLE [dbo].[IntegrationJob] DROP CONSTRAINT [DF_IntegrationJob_FileProcessed]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InventoryTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_InventoryTransaction]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[InventoryTransaction]', 'U'))
ALTER TABLE [dbo].[InventoryTransaction] DROP CONSTRAINT [PK_InventoryTransaction]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InventoryTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InventoryTransactionId' AND object_id = OBJECT_ID(N'[dbo].[InventoryTransaction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InventoryTransaction_InventoryTransactionId]', 'D'))
ALTER TABLE [dbo].[InventoryTransaction] DROP CONSTRAINT [DF_InventoryTransaction_InventoryTransactionId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InventoryTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TransactionDate' AND object_id = OBJECT_ID(N'[dbo].[InventoryTransaction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InventoryTransaction_TransactionDate]', 'D'))
ALTER TABLE [dbo].[InventoryTransaction] DROP CONSTRAINT [DF_InventoryTransaction_TransactionDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InventoryTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[InventoryTransaction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InventoryTransaction_Description]', 'D'))
ALTER TABLE [dbo].[InventoryTransaction] DROP CONSTRAINT [DF_InventoryTransaction_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InventoryTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount' AND object_id = OBJECT_ID(N'[dbo].[InventoryTransaction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InventoryTransaction_TransactionQty]', 'D'))
ALTER TABLE [dbo].[InventoryTransaction] DROP CONSTRAINT [DF_InventoryTransaction_TransactionQty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceHistoryLine]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_InvoiceHistoryLine]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[InvoiceHistoryLine]', 'U'))
ALTER TABLE [dbo].[InvoiceHistoryLine] DROP CONSTRAINT [PK_InvoiceHistoryLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceHistory]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_InvoiceHistory]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[InvoiceHistory]', 'U'))
ALTER TABLE [dbo].[InvoiceHistory] DROP CONSTRAINT [PK_InvoiceHistory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceHistory]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceDate' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistory]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceHistory_InvoiceDate]', 'D'))
ALTER TABLE [dbo].[InvoiceHistory] DROP CONSTRAINT [DF_InvoiceHistory_InvoiceDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceHistory]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DueDate' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistory]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceHistory_DueDate]', 'D'))
ALTER TABLE [dbo].[InvoiceHistory] DROP CONSTRAINT [DF_InvoiceHistory_DueDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceHistory]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsOpen' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistory]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceHistory_IsOpen]', 'D'))
ALTER TABLE [dbo].[InvoiceHistory] DROP CONSTRAINT [DF_InvoiceHistory_IsOpen]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_InvoiceLine]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [PK_InvoiceLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceLineId' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_InvoiceLineId]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_InvoiceLineId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceNumber' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_InvoiceNumber]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_InvoiceNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceSequence' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_InvoiceSequence]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_InvoiceSequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceLineNumber' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_InvoiceLine]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_InvoiceLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OrderNumber' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_OrderNumber]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_OrderNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OrderLine' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_OrderLine]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_OrderLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OrderRelease' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_OrderRelease]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_OrderRelease]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductName' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_Item]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_Item]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QuantityInvoiced' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_QuantityInvoiced]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_QuantityInvoiced]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Discount' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_Discount]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_Discount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Cost' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_Cost]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_Cost]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Price' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_Price]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_Price]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OldPrice' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_OldPrice]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_OldPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'NewPrice' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_NewPrice]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_NewPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProcessIdentifier' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_ProcessInd]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_ProcessInd]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ConsignmentType' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_ConsignmentType]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_ConsignmentType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TaxCode1' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_TaxCode1]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_TaxCode1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TaxCode2' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_TaxCode2]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_TaxCode2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TaxDate' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_TaxDate]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_TaxDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerPO' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_CustomerPO]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_CustomerPO]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RestockFee' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_RestockFee]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_RestockFee]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DONumber' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_DONumber]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_DONumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DOLine' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_DOLine]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_DOLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DOSequence' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_DOSequence]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_DOSequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OriginalInvoiceNumber' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_OriginalInvoiceNumber]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_OriginalInvoiceNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ReasonText' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_ReasonText]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_ReasonText]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductDescription' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_ProductDescription]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_ProductDescription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductCode' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_ProductCode]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_ProductCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QuantityOrdered' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceLine_QuantityOrdered]', 'D'))
ALTER TABLE [dbo].[InvoiceLine] DROP CONSTRAINT [DF_InvoiceLine_QuantityOrdered]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Invoice]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [PK_Invoice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceId' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_InvoiceId]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_InvoiceId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceDate' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_InvoiceDate]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_InvoiceDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TermsCode' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_TermsCode]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_TermsCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipCode' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_ShipCode]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_ShipCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OrderNumber' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_OrderNumber]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_OrderNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QuantityOfPackages' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_QuantityOfPackages]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_QuantityOfPackages]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipDate' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_ShipDate]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_ShipDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MiscellaneousCharges' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_MiscellaneousCharges]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_MiscellaneousCharges]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PrepaidAmount' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_PrepaidAmount]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_PrepaidAmount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Freight' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_Freight]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_Freight]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Cost' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_Cost]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_Cost]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Price' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_Price]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_Price]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillType' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_BillType]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_BillType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ExchangeRate' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_ExchangeRate]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_ExchangeRate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'UseExchangeRate' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_UseExchangeRate]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_UseExchangeRate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TaxCode1' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_TaxCode1]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_TaxCode1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TaxCode2' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_TaxCode2]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_TaxCode2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TaxDate' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_TaxDate]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_TaxDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ECCode' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_ECCode]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_ECCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FreightTaxCode1' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_FreightTaxCode1]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_FreightTaxCode1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FreightTaxCode2' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_FreightTaxCode2]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_FreightTaxCode2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MiscellaneousTaxCode1' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_MiscellaneousTaxCode1]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_MiscellaneousTaxCode1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MiscellaneousTaxCode2' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_MiscellaneousTaxCode2]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_MiscellaneousTaxCode2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Discount' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_Discount]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_Discount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DONumber' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_DONumber]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_DONumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Salesman' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_Salesman]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_Salesman]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'State' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_State]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_State]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceNumber' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_InvoiceNumber]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_InvoiceNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceSequence' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_InvoiceSequence]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_InvoiceSequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerPO' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_CustomerPO]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_CustomerPO]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Total' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_Total]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_Total]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OriginalTotal' AND object_id = OBJECT_ID(N'[dbo].[Invoice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Invoice_OriginalTotal]', 'D'))
ALTER TABLE [dbo].[Invoice] DROP CONSTRAINT [DF_Invoice_OriginalTotal]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_IntegrationJobDefinitionPostprocessorParameter]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U'))
ALTER TABLE [dbo].[JobDefinitionParameter] DROP CONSTRAINT [PK_IntegrationJobDefinitionPostprocessorParameter]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IntegrationJobDefinitionPostprocessorParameterId' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionPostprocessorParameter_IntegrationJobDefinitionPostprocessorParameterId]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionPostprocessorParameter_IntegrationJobDefinitionPostprocessorParameterId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Sequence' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionPostprocessorParameter_Sequence]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionPostprocessorParameter_Sequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ValueType' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionPostprocessorParameter_ValueType]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionPostprocessorParameter_ValueType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DefaultValue' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionPostprocessorParameter_DefaultValue]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionPostprocessorParameter_DefaultValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Prompt' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionPostprocessorParameter_Prompt]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionPostprocessorParameter_Prompt]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionPostprocessorParameter_Name]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionPostprocessorParameter_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepFieldMap]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_IntegrationJobDefinitionStepFieldMap]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] DROP CONSTRAINT [PK_IntegrationJobDefinitionStepFieldMap]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepFieldMap]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IntegrationJobDefinitionStepFieldMapId' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepFieldMap_IntegrationJobDefinitionStepFieldMapId]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepFieldMap_IntegrationJobDefinitionStepFieldMapId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepFieldMap]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FieldType' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepFieldMap_FieldType]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepFieldMap_FieldType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepFieldMap]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FromProperty' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepFieldMap_FromProperty]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepFieldMap_FromProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepFieldMap]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ToProperty' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepFieldMap_ToProperty]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepFieldMap_ToProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepFieldMap]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Overwrite' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepFieldMap_Overwrite]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepFieldMap_Overwrite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepFieldMap]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsErpKey' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepFieldMap_IsErpKey]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepFieldMap_IsErpKey]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_IntegrationJobDefinitionStepParameter]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] DROP CONSTRAINT [PK_IntegrationJobDefinitionStepParameter]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IntegrationJobDefinitionStepParameterId' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepParameter_IntegrationJobDefinitionStepParameterId]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepParameter_IntegrationJobDefinitionStepParameterId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Sequence' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepParameter_Sequence]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepParameter_Sequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ValueType' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepParameter_ValueType]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepParameter_ValueType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DefaultValue' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepParameter_DefaultValue]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepParameter_DefaultValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Prompt' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepParameter_Prompt]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepParameter_Prompt]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStepParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStepParameter_Name]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] DROP CONSTRAINT [DF_IntegrationJobDefinitionStepParameter_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_IntegrationJobDefinitionStep]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [PK_IntegrationJobDefinitionStep]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IntegrationJobDefinitionStepId' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_IntegrationJobDefinitionStepId]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_IntegrationJobDefinitionStepId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Sequence' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_Sequence]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_Sequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_Name]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ObjectName' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_Object]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_Object]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IntegrationProcessorOverride' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_IntegrationProcessorOverride]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_IntegrationProcessorOverride]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SelectClause' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_SelectClause]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_SelectClause]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FromClause' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_FromClause]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_FromClause]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'WhereClause' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_WhereClause]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_WhereClause]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ParameterizedWhereClause' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_ParamaterizedWhereClause]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_ParamaterizedWhereClause]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DeleteAction' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_DeleteAction]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_DeleteAction]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DeleteActionFieldToSet' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_DeleteActionFieldToSet]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_DeleteActionFieldToSet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DeleteActionValueToSet' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_DeleteActionValueToSet]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_DeleteActionValueToSet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SkipHeaderRow' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinitionStep_SkipHeaderRow]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] DROP CONSTRAINT [DF_IntegrationJobDefinitionStep_SkipHeaderRow]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_IntegrationJobDefinition]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [PK_IntegrationJobDefinition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IntegrationJobDefinitionId' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_IntegrationJobDefinitionId]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_IntegrationJobDefinitionId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_Name]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_Description]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'JobType' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_JobType]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_JobType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DebuggingEnabled' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_DebuggingEnabled]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_DebuggingEnabled]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PassThroughJob' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_PassThroughJob]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_PassThroughJob]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'NotifyEmail' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_NotifyEmail]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_NotifyEmail]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'NotifyCondition' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_NotifyCondition]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_NotifyCondition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PassDataSetToLinkedJob' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_PassDatasetToLinkedJob]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_PassDatasetToLinkedJob]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'UseDeltaDataSet' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_UseDeltaDataset]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_UseDeltaDataset]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PreProcessor' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_PreProcessor]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_PreProcessor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IntegrationProcessor' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_IntegrationProcessor]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_IntegrationProcessor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PostProcessor' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_PostProcessor]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_PostProcessor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LastRunJobNumber' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_LastRunJobNumber]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_LastRunJobNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LastRunStatus' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_LastRunStatus]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_LastRunStatus]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RecurringJob' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_RecurringJob]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_RecurringJob]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RecurringInterval' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_RecurringMinuteInterval]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_RecurringMinuteInterval]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RecurringType' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_RecurringType]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_RecurringType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RecurringStartDay' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_RecurringStartDay]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_RecurringStartDay]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RunStepsInParallel' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_RunStepsInParallel]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_RunStepsInParallel]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LinkedJobCondition' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobDefinition_LinkedJobCondition]', 'D'))
ALTER TABLE [dbo].[JobDefinition] DROP CONSTRAINT [DF_IntegrationJobDefinition_LinkedJobCondition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Language]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Language]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Language]', 'U'))
ALTER TABLE [dbo].[Language] DROP CONSTRAINT [PK_Language]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Language]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HasDeviceSpecificContent' AND object_id = OBJECT_ID(N'[dbo].[Language]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Language_HasDeviceSpecificContent]', 'D'))
ALTER TABLE [dbo].[Language] DROP CONSTRAINT [DF_Language_HasDeviceSpecificContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Language]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HasPersonaSpecificContent' AND object_id = OBJECT_ID(N'[dbo].[Language]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Language_HasPersonaSpecificContent]', 'D'))
ALTER TABLE [dbo].[Language] DROP CONSTRAINT [DF_Language_HasPersonaSpecificContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Language]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ImageFilePath' AND object_id = OBJECT_ID(N'[dbo].[Language]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Language_ImageFilePath]', 'D'))
ALTER TABLE [dbo].[Language] DROP CONSTRAINT [DF_Language_ImageFilePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Language]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[Language]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Language_IsDefault]', 'D'))
ALTER TABLE [dbo].[Language] DROP CONSTRAINT [DF_Language_IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Menu]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Menu]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Menu]', 'U'))
ALTER TABLE [dbo].[Menu] DROP CONSTRAINT [PK_Menu]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Menu]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_Description]', 'D'))
ALTER TABLE [dbo].[Menu] DROP CONSTRAINT [DF_Menu_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Menu]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Image' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_Image]', 'D'))
ALTER TABLE [dbo].[Menu] DROP CONSTRAINT [DF_Menu_Image]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Menu]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_IsActive]', 'D'))
ALTER TABLE [dbo].[Menu] DROP CONSTRAINT [DF_Menu_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Menu]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Target' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_Target]', 'D'))
ALTER TABLE [dbo].[Menu] DROP CONSTRAINT [DF_Menu_Target]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Menu]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_LanguageCode]', 'D'))
ALTER TABLE [dbo].[Menu] DROP CONSTRAINT [DF_Menu_LanguageCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Menu]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsGlobalItem' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_IsGlobalItem]', 'D'))
ALTER TABLE [dbo].[Menu] DROP CONSTRAINT [DF_Menu_IsGlobalItem]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Menu]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsSystemItem' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_IsSystemItem]', 'D'))
ALTER TABLE [dbo].[Menu] DROP CONSTRAINT [DF_Menu_IsSystemItem]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Menu]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShowInList' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_ShowInList]', 'D'))
ALTER TABLE [dbo].[Menu] DROP CONSTRAINT [DF_Menu_ShowInList]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[MessageAudit]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_MessageAudit]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U'))
ALTER TABLE [dbo].[MessageAudit] DROP CONSTRAINT [PK_MessageAudit]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[MessageAudit]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedDate' AND object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_MessageAudit_CreatedDate]', 'D'))
ALTER TABLE [dbo].[MessageAudit] DROP CONSTRAINT [DF_MessageAudit_CreatedDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[MessageStatus]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_MessageStatus]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageStatus]', 'U'))
ALTER TABLE [dbo].[MessageStatus] DROP CONSTRAINT [PK_MessageStatus]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[MessageStatus]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HasRead' AND object_id = OBJECT_ID(N'[dbo].[MessageStatus]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_MessageStatus_HasRead]', 'D'))
ALTER TABLE [dbo].[MessageStatus] DROP CONSTRAINT [DF_MessageStatus_HasRead]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[MessageTarget]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_MessageTarget]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageTarget]', 'U'))
ALTER TABLE [dbo].[MessageTarget] DROP CONSTRAINT [PK_MessageTarget]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Message]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Message_1]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Message]', 'U'))
ALTER TABLE [dbo].[Message] DROP CONSTRAINT [PK_Message_1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Message]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DateToDisplay' AND object_id = OBJECT_ID(N'[dbo].[Message]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Message_DateToDisplay]', 'D'))
ALTER TABLE [dbo].[Message] DROP CONSTRAINT [DF_Message_DateToDisplay]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Message]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[Message]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Message_LanguageCode]', 'D'))
ALTER TABLE [dbo].[Message] DROP CONSTRAINT [DF_Message_LanguageCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[MiscellaneousCode]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_MiscellaneousCode]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[MiscellaneousCode]', 'U'))
ALTER TABLE [dbo].[MiscellaneousCode] DROP CONSTRAINT [PK_MiscellaneousCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[MiscellaneousCode]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdditionalInfo' AND object_id = OBJECT_ID(N'[dbo].[MiscellaneousCode]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_MiscellaneousCode_AdditionalInfo]', 'D'))
ALTER TABLE [dbo].[MiscellaneousCode] DROP CONSTRAINT [DF_MiscellaneousCode_AdditionalInfo]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[MiscellaneousCode]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[MiscellaneousCode]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_MiscellaneousCode_Description]', 'D'))
ALTER TABLE [dbo].[MiscellaneousCode] DROP CONSTRAINT [DF_MiscellaneousCode_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderHistoryLine]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_OrderHistoryLine]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderHistoryLine]', 'U'))
ALTER TABLE [dbo].[OrderHistoryLine] DROP CONSTRAINT [PK_OrderHistoryLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderHistoryLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[OrderHistoryLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderHistoryLine_Description]', 'D'))
ALTER TABLE [dbo].[OrderHistoryLine] DROP CONSTRAINT [DF_OrderHistoryLine_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderHistory]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_OrderHistory]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderHistory]', 'U'))
ALTER TABLE [dbo].[OrderHistory] DROP CONSTRAINT [PK_OrderHistory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderHistory]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OrderDate' AND object_id = OBJECT_ID(N'[dbo].[OrderHistory]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderHistory_OrderDate]', 'D'))
ALTER TABLE [dbo].[OrderHistory] DROP CONSTRAINT [DF_OrderHistory_OrderDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderHistory]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ModifyDate' AND object_id = OBJECT_ID(N'[dbo].[OrderHistory]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderHistory_ModifyDate]', 'D'))
ALTER TABLE [dbo].[OrderHistory] DROP CONSTRAINT [DF_OrderHistory_ModifyDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderLineConfigurationValue]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_OrderLineConfigurationValue]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineConfigurationValue]', 'U'))
ALTER TABLE [dbo].[OrderLineConfigurationValue] DROP CONSTRAINT [PK_OrderLineConfigurationValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderLineProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_OrderLineAttribute]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]', 'U'))
ALTER TABLE [dbo].[OrderLineProperty] DROP CONSTRAINT [PK_OrderLineAttribute]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderLineProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OrderLineAttributeId' AND object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLineAttribute_OrderLineAttributeId]', 'D'))
ALTER TABLE [dbo].[OrderLineProperty] DROP CONSTRAINT [DF_OrderLineAttribute_OrderLineAttributeId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderLineProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLineAttribute_Name]', 'D'))
ALTER TABLE [dbo].[OrderLineProperty] DROP CONSTRAINT [DF_OrderLineAttribute_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderLineProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Value' AND object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLineAttribute_Value]', 'D'))
ALTER TABLE [dbo].[OrderLineProperty] DROP CONSTRAINT [DF_OrderLineAttribute_Value]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderLineProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Hidden' AND object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLineAttribute_Hidden]', 'D'))
ALTER TABLE [dbo].[OrderLineProperty] DROP CONSTRAINT [DF_OrderLineAttribute_Hidden]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderLineRequisition]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_OrderLineRequisition]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]', 'U'))
ALTER TABLE [dbo].[OrderLineRequisition] DROP CONSTRAINT [PK_OrderLineRequisition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderLineRfq]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_OrderLineRfq]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRfq]', 'U'))
ALTER TABLE [dbo].[OrderLineRfq] DROP CONSTRAINT [PK_OrderLineRfq]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderLine]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_OrderLine]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] DROP CONSTRAINT [PK_OrderLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DueDate' AND object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLine_DueDate]', 'D'))
ALTER TABLE [dbo].[OrderLine] DROP CONSTRAINT [DF_OrderLine_DueDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPromotionItem' AND object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLine_IsPromotionItem]', 'D'))
ALTER TABLE [dbo].[OrderLine] DROP CONSTRAINT [DF_OrderLine_IsPromotionItem]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderPromotionCode]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PromotionCode]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderPromotionCode]', 'U'))
ALTER TABLE [dbo].[OrderPromotionCode] DROP CONSTRAINT [PK_PromotionCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderPromotionCode]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PromotionCodeId' AND object_id = OBJECT_ID(N'[dbo].[OrderPromotionCode]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PromotionCode_PromotionCodeId]', 'D'))
ALTER TABLE [dbo].[OrderPromotionCode] DROP CONSTRAINT [DF_PromotionCode_PromotionCodeId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[OrderPromotionCode]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Code' AND object_id = OBJECT_ID(N'[dbo].[OrderPromotionCode]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PromotionCode_Code]', 'D'))
ALTER TABLE [dbo].[OrderPromotionCode] DROP CONSTRAINT [DF_PromotionCode_Code]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Persona]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Persona]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Persona]', 'U'))
ALTER TABLE [dbo].[Persona] DROP CONSTRAINT [PK_Persona]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Persona]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Persona]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Persona_Description]', 'D'))
ALTER TABLE [dbo].[Persona] DROP CONSTRAINT [DF_Persona_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Persona]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[Persona]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Persona_Active]', 'D'))
ALTER TABLE [dbo].[Persona] DROP CONSTRAINT [DF_Persona_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Persona]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[Persona]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Persona_IsDefault]', 'D'))
ALTER TABLE [dbo].[Persona] DROP CONSTRAINT [DF_Persona_IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Plugin]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Plugin]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Plugin]', 'U'))
ALTER TABLE [dbo].[Plugin] DROP CONSTRAINT [PK_Plugin]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Plugin]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Plugin]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Plugin_IsActive]', 'D'))
ALTER TABLE [dbo].[Plugin] DROP CONSTRAINT [DF_Plugin_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PriceMatrix]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PriceMatrix]', 'U'))
ALTER TABLE [dbo].[PriceMatrix] DROP CONSTRAINT [PK_PriceMatrix]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PriceMatrix_Batch]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [PK_PriceMatrix_Batch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceMatrixId' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceMatrixId]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceMatrixId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RecordType' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_RecordType]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_RecordType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CurrencyCode' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_CurrencyCode]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_CurrencyCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Warehouse' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Warehouse]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Warehouse]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'UnitOfMeasure' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_UnitOfMeasure]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_UnitOfMeasure]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerKeyPart' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_CustomerKeyPart]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_CustomerKeyPart]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductKeyPart' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_ProductKeyPart]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_ProductKeyPart]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CalculationFlags' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_CalculationFlags]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_CalculationFlags]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceBasis01' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceBasis01]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceBasis01]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceBasis02' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceBasis02]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceBasis02]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceBasis03' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceBasis03]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceBasis03]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceBasis04' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceBasis04]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceBasis04]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceBasis05' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceBasis05]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceBasis05]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceBasis06' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceBasis06]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceBasis06]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceBasis07' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceBasis07]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceBasis07]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceBasis08' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceBasis08]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceBasis08]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceBasis09' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceBasis09]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceBasis09]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceBasis10' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceBasis10]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceBasis10]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PriceBasis11' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_PriceBasis11]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_PriceBasis11]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdjustmentType01' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AdjustmentType01]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AdjustmentType01]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdjustmentType02' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AdjustmentType02]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AdjustmentType02]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdjustmentType03' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AdjustmentType03]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AdjustmentType03]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdjustmentType04' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AdjustmentType04]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AdjustmentType04]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdjustmentType05' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AdjustmentType05]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AdjustmentType05]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdjustmentType06' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AdjustmentType06]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AdjustmentType06]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdjustmentType07' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AdjustmentType07]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AdjustmentType07]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdjustmentType08' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AdjustmentType08]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AdjustmentType08]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdjustmentType09' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AdjustmentType09]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AdjustmentType09]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdjustmentType10' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AdjustmentType10]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AdjustmentType10]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdjustmentType11' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AdjustmentType11]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AdjustmentType11]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty01' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_BreakQty01]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_BreakQty01]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty02' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_BreakQty02]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_BreakQty02]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty03' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_BreakQty03]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_BreakQty03]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty04' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_BreakQty04]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_BreakQty04]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty05' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_BreakQty05]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_BreakQty05]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty06' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_BreakQty06]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_BreakQty06]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty07' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_BreakQty07]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_BreakQty07]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty08' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_BreakQty08]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_BreakQty08]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty09' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_BreakQty09]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_BreakQty09]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty10' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_BreakQty10]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_BreakQty10]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty11' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_BreakQty11]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_BreakQty11]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount01' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Amount01]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Amount01]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount02' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Amount02]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Amount02]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount03' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Amount03]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Amount03]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount04' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Amount04]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Amount04]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount05' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Amount05]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Amount05]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount06' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Amount06]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Amount06]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount07' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Amount07]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Amount07]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount08' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Amount08]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Amount08]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount09' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Amount09]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Amount09]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount10' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Amount10]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Amount10]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount11' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_Amount11]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_Amount11]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltAmount01' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AltAmount01]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AltAmount01]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltAmount02' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AltAmount02]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AltAmount02]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltAmount03' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AltAmount03]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AltAmount03]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltAmount04' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AltAmount04]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AltAmount04]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltAmount05' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AltAmount05]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AltAmount05]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltAmount06' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AltAmount06]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AltAmount06]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltAmount07' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AltAmount07]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AltAmount07]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltAmount08' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AltAmount08]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AltAmount08]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltAmount09' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AltAmount09]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AltAmount09]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltAmount10' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AltAmount10]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AltAmount10]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltAmount11' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PriceMatrix_Batch_AltAmount11]', 'D'))
ALTER TABLE [dbo].[PriceMatrix_Batch] DROP CONSTRAINT [DF_PriceMatrix_Batch_AltAmount11]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductAttributeValue]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ProductFilterValue]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductAttributeValue]', 'U'))
ALTER TABLE [dbo].[ProductAttributeValue] DROP CONSTRAINT [PK_ProductFilterValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductCost]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ProductCost]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductCost]', 'U'))
ALTER TABLE [dbo].[ProductCost] DROP CONSTRAINT [PK_ProductCost]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductCost]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductCostId' AND object_id = OBJECT_ID(N'[dbo].[ProductCost]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductCost_ProductCostId]', 'D'))
ALTER TABLE [dbo].[ProductCost] DROP CONSTRAINT [DF_ProductCost_ProductCostId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductCost]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductId' AND object_id = OBJECT_ID(N'[dbo].[ProductCost]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductCost_ProductId]', 'D'))
ALTER TABLE [dbo].[ProductCost] DROP CONSTRAINT [DF_ProductCost_ProductId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductCost]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SiteName' AND object_id = OBJECT_ID(N'[dbo].[ProductCost]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductCost_SiteName]', 'D'))
ALTER TABLE [dbo].[ProductCost] DROP CONSTRAINT [DF_ProductCost_SiteName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductCost]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Cost' AND object_id = OBJECT_ID(N'[dbo].[ProductCost]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductCost_Cost]', 'D'))
ALTER TABLE [dbo].[ProductCost] DROP CONSTRAINT [DF_ProductCost_Cost]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ProductPrice]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [PK_ProductPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductPriceId' AND object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductPrice_ProductPriceId]', 'D'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [DF_ProductPrice_ProductPriceId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BreakQty' AND object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductPrice_BreakQty]', 'D'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [DF_ProductPrice_BreakQty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Price' AND object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductPrice_Price]', 'D'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [DF_ProductPrice_Price]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductPrice_Active]', 'D'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [DF_ProductPrice_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PricePerPiece' AND object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductPrice_PricePerPiece]', 'D'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [DF_ProductPrice_PricePerPiece]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsOnSale' AND object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductPrice_IsOnSale]', 'D'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [DF_ProductPrice_IsOnSale]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalePrice' AND object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductPrice_SalePrice]', 'D'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [DF_ProductPrice_SalePrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RegularMarkup' AND object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductPrice_RegularMarkup]', 'D'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [DF_ProductPrice_RegularMarkup]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SaleMarkup' AND object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductPrice_SaleMarkup]', 'D'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [DF_ProductPrice_SaleMarkup]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CurrencyCode' AND object_id = OBJECT_ID(N'[dbo].[ProductPrice]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductPrice_CurrencyCode]', 'D'))
ALTER TABLE [dbo].[ProductPrice] DROP CONSTRAINT [DF_ProductPrice_CurrencyCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ProductProperty]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductProperty]', 'U'))
ALTER TABLE [dbo].[ProductProperty] DROP CONSTRAINT [PK_ProductProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductUnitOfMeasure]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ProductUnitOfMeasure]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]', 'U'))
ALTER TABLE [dbo].[ProductUnitOfMeasure] DROP CONSTRAINT [PK_ProductUnitOfMeasure]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductUnitOfMeasure]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductUnitOfMeasure_Description]', 'D'))
ALTER TABLE [dbo].[ProductUnitOfMeasure] DROP CONSTRAINT [DF_ProductUnitOfMeasure_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductUnitOfMeasure]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RoundingRule' AND object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductUnitOfMeasure_RoundingRule]', 'D'))
ALTER TABLE [dbo].[ProductUnitOfMeasure] DROP CONSTRAINT [DF_ProductUnitOfMeasure_RoundingRule]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductUnitOfMeasure]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductUnitOfMeasure_IsDefault]', 'D'))
ALTER TABLE [dbo].[ProductUnitOfMeasure] DROP CONSTRAINT [DF_ProductUnitOfMeasure_IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductWarehouse]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ProductWarehouse]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductWarehouse]', 'U'))
ALTER TABLE [dbo].[ProductWarehouse] DROP CONSTRAINT [PK_ProductWarehouse]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ProductWarehouse]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDiscontinued' AND object_id = OBJECT_ID(N'[dbo].[ProductWarehouse]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductWarehouse_IsDiscontinued]', 'D'))
ALTER TABLE [dbo].[ProductWarehouse] DROP CONSTRAINT [DF_ProductWarehouse_IsDiscontinued]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Product]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [PK_Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_Description]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QtyPerPackageLength' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_QtyPerPackageLength]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_QtyPerPackageLength]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QtyPerPackageWidth' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_QtyPerPackageWidth]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_QtyPerPackageWidth]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QtyPerPackageHeight' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_QtyPerPackageHeight]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_QtyPerPackageHeight]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'EachDescription' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_EachDescription]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_EachDescription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'StyleSheet' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_StyleSheet]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_StyleSheet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'UserVendorMarkup' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_UserVendorMarkup]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_UserVendorMarkup]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ERPDescription' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_ERPDescription]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_ERPDescription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SmallImagePath' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SmallImagePath]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SmallImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MediumImagePath' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_MediumImagePath]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_MediumImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LargeImagePath' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_LargeImagePath]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_LargeImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_Active]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PageTitle' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_PageTitle]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_PageTitle]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DisplayPricePerPiece' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_DisplayPricePerPiece]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_DisplayPricePerPiece]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsGiftCard' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsGiftCard]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_IsGiftCard]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AllowAnyGiftCardAmount' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_AllowAnyGiftCardAmount]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_AllowAnyGiftCardAmount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OutOfStock' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_OutOfStock]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_OutOfStock]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ERPManaged' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_ERPManaged]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_ERPManaged]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsSubscription' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsSubscription]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_IsSubscription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionFixedPrice' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionFixedPrice]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionFixedPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionIncludeInInitialOrder' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionIncludeInInitialOrder]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionIncludeInInitialOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionAllMonths' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionAllMonths]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionAllMonths]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionJanuary' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionJanuary]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionJanuary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionFebruary' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionFebruary]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionFebruary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionMarch' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionMarch]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionMarch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionApril' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionApril]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionApril]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionMay' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionMay]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionMay]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionJune' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionJune]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionJune]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionJuly' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionJuly]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionJuly]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionAugust' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionAugust]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionAugust]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionSeptember' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionSeptember]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionSeptember]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionOctober' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionOctober]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionOctober]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionNovember' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionNovember]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionNovember]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionDecember' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionDecember]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_SubscriptionDecember]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'UseVendorMarkup' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_UseVendorMarkup]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_UseVendorMarkup]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TrackInventory' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_TrackInventory]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_TrackInventory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsConfigured' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsConfigured]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_IsConfigured]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Cost' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_Cost]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_Cost]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HasMsds' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_HasMsds]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_HasMsds]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsHazardousGood' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsHazardousGood]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_IsHazardousGood]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDiscontinued' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsDiscontinued]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_IsDiscontinued]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsSpecialOrder' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsSpecialOrder]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_IsSpecialOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsFixedConfiguration' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsFixedConfiguration]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_IsFixedConfiguration]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AltText' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_AltText]', 'D'))
ALTER TABLE [dbo].[Product] DROP CONSTRAINT [DF_Product_AltText]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PromotionResult]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PromotionResult]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionResult]', 'U'))
ALTER TABLE [dbo].[PromotionResult] DROP CONSTRAINT [PK_PromotionResult]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PromotionResult]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Visible' AND object_id = OBJECT_ID(N'[dbo].[PromotionResult]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PromotionResult_Visible]', 'D'))
ALTER TABLE [dbo].[PromotionResult] DROP CONSTRAINT [DF_PromotionResult_Visible]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PromotionRule]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PromotionRule]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] DROP CONSTRAINT [PK_PromotionRule]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Promotion]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Promotion]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U'))
ALTER TABLE [dbo].[Promotion] DROP CONSTRAINT [PK_Promotion]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Promotion]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DisplayMessage' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_DisplayMessage]', 'D'))
ALTER TABLE [dbo].[Promotion] DROP CONSTRAINT [DF_Promotion_DisplayMessage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Promotion]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_Description]', 'D'))
ALTER TABLE [dbo].[Promotion] DROP CONSTRAINT [DF_Promotion_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Promotion]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DiscountAmount' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_Amount]', 'D'))
ALTER TABLE [dbo].[Promotion] DROP CONSTRAINT [DF_Promotion_Amount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Promotion]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Table_1_ActiveDate]', 'D'))
ALTER TABLE [dbo].[Promotion] DROP CONSTRAINT [DF_Table_1_ActiveDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Promotion]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPercentage' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_IsPercentage]', 'D'))
ALTER TABLE [dbo].[Promotion] DROP CONSTRAINT [DF_Promotion_IsPercentage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Promotion]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsFreight' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_IsFreight]', 'D'))
ALTER TABLE [dbo].[Promotion] DROP CONSTRAINT [DF_Promotion_IsFreight]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Promotion]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsAutomatic' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Table_1_AutomaticPromo]', 'D'))
ALTER TABLE [dbo].[Promotion] DROP CONSTRAINT [DF_Table_1_AutomaticPromo]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Promotion]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_IsActive]', 'D'))
ALTER TABLE [dbo].[Promotion] DROP CONSTRAINT [DF_Promotion_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutCustomerUserProfileMap]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PunchOutCustomerUserProfileMap]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutCustomerUserProfileMap]', 'U'))
ALTER TABLE [dbo].[PunchOutCustomerUserProfileMap] DROP CONSTRAINT [PK_PunchOutCustomerUserProfileMap]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestExtrinsic]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PunchOutOrderRequestExtrinsic]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestExtrinsic]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestExtrinsic] DROP CONSTRAINT [PK_PunchOutOrderRequestExtrinsic]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestItemOut]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PunchOutOrderRequestItemOut]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [PK_PunchOutOrderRequestItemOut]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestItemOut]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PunchOutOrderRequestItemOutId' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_PunchOutOrderRequestItemOutId]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [DF_PunchOutOrderRequestItemOut_PunchOutOrderRequestItemOutId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestItemOut]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreateDate' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_CreateDate]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [DF_PunchOutOrderRequestItemOut_CreateDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestItemOut]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_BillToStreet]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [DF_PunchOutOrderRequestItemOut_BillToStreet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestItemOut]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet2' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_BillToStreet2]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [DF_PunchOutOrderRequestItemOut_BillToStreet2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestItemOut]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet3' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_BillToStreet3]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [DF_PunchOutOrderRequestItemOut_BillToStreet3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestItemOut]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet4' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_BillToStreet4]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [DF_PunchOutOrderRequestItemOut_BillToStreet4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestItemOut]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet2' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_ShipToStreet2]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [DF_PunchOutOrderRequestItemOut_ShipToStreet2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestItemOut]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet3' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_ShipToStreet3]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [DF_PunchOutOrderRequestItemOut_ShipToStreet3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestItemOut]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet4' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_ShipToStreet4]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] DROP CONSTRAINT [DF_PunchOutOrderRequestItemOut_ShipToStreet4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestMessage]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PunchOutOrderRequestValidationMessage]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] DROP CONSTRAINT [PK_PunchOutOrderRequestValidationMessage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestMessage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreateDate' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestValidationMessage_CreateDate]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] DROP CONSTRAINT [DF_PunchOutOrderRequestValidationMessage_CreateDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestMessage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PunchOutOrderRequestValidationMessageId' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestValidationMessage_PunchOutOrderRequestValidationMessageId]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] DROP CONSTRAINT [DF_PunchOutOrderRequestValidationMessage_PunchOutOrderRequestValidationMessageId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestMessage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PunchOutOrderRequestValidationMessageType' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestValidationMessage_PunchOutOrderRequestValidationMessageType]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] DROP CONSTRAINT [DF_PunchOutOrderRequestValidationMessage_PunchOutOrderRequestValidationMessageType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequestMessage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Message' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestValidationMessage_Message]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] DROP CONSTRAINT [DF_PunchOutOrderRequestValidationMessage_Message]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PunchOutOrderRequest]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [PK_PunchOutOrderRequest]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreateDate' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_CreateDate]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_CreateDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShippingDescription' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShippingDescription]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_ShippingDescription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToEmail' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToEmail]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_BillToEmail]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToEmail' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToEmail]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_ShipToEmail]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet2' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToStreet2]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_BillToStreet2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet3' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToStreet3]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_BillToStreet3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet4' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToStreet4]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_BillToStreet4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToTelephoneNumber' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToTelephoneNumber]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_BillToTelephoneNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToTelephoneIsoCountryCode' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToTelephoneIsoCountryCode]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_BillToTelephoneIsoCountryCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToTelephoneAreaOrCityCode' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToTelephoneAreaOrCityCode]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_BillToTelephoneAreaOrCityCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet2' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToStreet2]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_ShipToStreet2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet3' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToStreet3]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_ShipToStreet3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet4' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToStreet4]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_ShipToStreet4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToTelephoneNumber' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToTelephoneNumber]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_ShipToTelephoneNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToTelephoneIsoCountryCode' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToTelephoneIsoCountryCode]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_ShipToTelephoneIsoCountryCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutOrderRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToTelephoneAreaOrCityCode' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToTelephoneAreaOrCityCode]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] DROP CONSTRAINT [DF_PunchOutOrderRequest_ShipToTelephoneAreaOrCityCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutSessionAccess]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PunchOutSessionAccess]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSessionAccess]', 'U'))
ALTER TABLE [dbo].[PunchOutSessionAccess] DROP CONSTRAINT [PK_PunchOutSessionAccess]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutSessionAccess]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreateDate' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSessionAccess]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutSessionAccess_CreateDate]', 'D'))
ALTER TABLE [dbo].[PunchOutSessionAccess] DROP CONSTRAINT [DF_PunchOutSessionAccess_CreateDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutSessionExtrinsic]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PunchOutSessionExtrinsic]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSessionExtrinsic]', 'U'))
ALTER TABLE [dbo].[PunchOutSessionExtrinsic] DROP CONSTRAINT [PK_PunchOutSessionExtrinsic]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutSessionItemIn]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PunchOutSessionItemIn]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSessionItemIn]', 'U'))
ALTER TABLE [dbo].[PunchOutSessionItemIn] DROP CONSTRAINT [PK_PunchOutSessionItemIn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutSession]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PunchOutSession]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSession]', 'U'))
ALTER TABLE [dbo].[PunchOutSession] DROP CONSTRAINT [PK_PunchOutSession]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutSession]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreateDate' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSession]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutSession_CreateDate]', 'D'))
ALTER TABLE [dbo].[PunchOutSession] DROP CONSTRAINT [DF_PunchOutSession_CreateDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutSession]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipAddressIdResolved' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSession]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutSession_ShipAddressIdResolved]', 'D'))
ALTER TABLE [dbo].[PunchOutSession] DROP CONSTRAINT [DF_PunchOutSession_ShipAddressIdResolved]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutSetupRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PunchOutSetupRequest]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSetupRequest]', 'U'))
ALTER TABLE [dbo].[PunchOutSetupRequest] DROP CONSTRAINT [PK_PunchOutSetupRequest]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[PunchOutSetupRequest]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreateDate' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSetupRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutSetupRequest_CreateDate]', 'D'))
ALTER TABLE [dbo].[PunchOutSetupRequest] DROP CONSTRAINT [DF_PunchOutSetupRequest_CreateDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[RestrictionGroup]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_RestrictionGroup]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[RestrictionGroup]', 'U'))
ALTER TABLE [dbo].[RestrictionGroup] DROP CONSTRAINT [PK_RestrictionGroup]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[RestrictionGroup]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UC_RestrictionGroup]', 'UQ') AND parent_object_id = OBJECT_ID(N'[dbo].[RestrictionGroup]', 'U'))
ALTER TABLE [dbo].[RestrictionGroup] DROP CONSTRAINT [UC_RestrictionGroup]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Review]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Review]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Review]', 'U'))
ALTER TABLE [dbo].[Review] DROP CONSTRAINT [PK_Review]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Review]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ReviewId' AND object_id = OBJECT_ID(N'[dbo].[Review]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Review_ReviewId]', 'D'))
ALTER TABLE [dbo].[Review] DROP CONSTRAINT [DF_Review_ReviewId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Review]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[Review]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Review_Name]', 'D'))
ALTER TABLE [dbo].[Review] DROP CONSTRAINT [DF_Review_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Review]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Review]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Review_Description]', 'D'))
ALTER TABLE [dbo].[Review] DROP CONSTRAINT [DF_Review_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Review]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[Review]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Review_Active]', 'D'))
ALTER TABLE [dbo].[Review] DROP CONSTRAINT [DF_Review_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Review]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Deactivate' AND object_id = OBJECT_ID(N'[dbo].[Review]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Review_Deactivate]', 'D'))
ALTER TABLE [dbo].[Review] DROP CONSTRAINT [DF_Review_Deactivate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[RuleClause]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_RuleClause]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleClause]', 'U'))
ALTER TABLE [dbo].[RuleClause] DROP CONSTRAINT [PK_RuleClause]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[RuleManager]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_RulesManager]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleManager]', 'U'))
ALTER TABLE [dbo].[RuleManager] DROP CONSTRAINT [PK_RulesManager]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[RuleTypeOption]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_RuleTypeOption]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleTypeOption]', 'U'))
ALTER TABLE [dbo].[RuleTypeOption] DROP CONSTRAINT [PK_RuleTypeOption]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[RuleType]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_RuleType]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleType]', 'U'))
ALTER TABLE [dbo].[RuleType] DROP CONSTRAINT [PK_RuleType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ScheduledTask]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ScheduledTask]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ScheduledTask]', 'U'))
ALTER TABLE [dbo].[ScheduledTask] DROP CONSTRAINT [PK_ScheduledTask]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ScheduledTask]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ScheduledTaskId' AND object_id = OBJECT_ID(N'[dbo].[ScheduledTask]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ScheduledTask_ScheduledTaskId]', 'D'))
ALTER TABLE [dbo].[ScheduledTask] DROP CONSTRAINT [DF_ScheduledTask_ScheduledTaskId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ScheduledTask]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Type' AND object_id = OBJECT_ID(N'[dbo].[ScheduledTask]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ScheduledTask_Type]', 'D'))
ALTER TABLE [dbo].[ScheduledTask] DROP CONSTRAINT [DF_ScheduledTask_Type]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ScheduledTask]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Parameter' AND object_id = OBJECT_ID(N'[dbo].[ScheduledTask]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ScheduledTask_Parameter]', 'D'))
ALTER TABLE [dbo].[ScheduledTask] DROP CONSTRAINT [DF_ScheduledTask_Parameter]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ScheduledTask]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MinuteInterval' AND object_id = OBJECT_ID(N'[dbo].[ScheduledTask]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ScheduledTask_MinuteInterval]', 'D'))
ALTER TABLE [dbo].[ScheduledTask] DROP CONSTRAINT [DF_ScheduledTask_MinuteInterval]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ScheduledTask]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsRealTime' AND object_id = OBJECT_ID(N'[dbo].[ScheduledTask]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ScheduledTask_IsRealTime]', 'D'))
ALTER TABLE [dbo].[ScheduledTask] DROP CONSTRAINT [DF_ScheduledTask_IsRealTime]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ScheduledTask]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ReturnAction' AND object_id = OBJECT_ID(N'[dbo].[ScheduledTask]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ScheduledTask_ReturnAction]', 'D'))
ALTER TABLE [dbo].[ScheduledTask] DROP CONSTRAINT [DF_ScheduledTask_ReturnAction]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ScheduledTask]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ResultData' AND object_id = OBJECT_ID(N'[dbo].[ScheduledTask]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ScheduledTask_ResultData]', 'D'))
ALTER TABLE [dbo].[ScheduledTask] DROP CONSTRAINT [DF_ScheduledTask_ResultData]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[SearchSynonym]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_SearchSynonymId]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[SearchSynonym]', 'U'))
ALTER TABLE [dbo].[SearchSynonym] DROP CONSTRAINT [PK_SearchSynonymId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[SearchSynonym]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Bidirectional' AND object_id = OBJECT_ID(N'[dbo].[SearchSynonym]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_SearchSynonym_Bidirectional]', 'D'))
ALTER TABLE [dbo].[SearchSynonym] DROP CONSTRAINT [DF_SearchSynonym_Bidirectional]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[SearchSynonym]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[SearchSynonym]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_SearchSynonym_LanguageCode]', 'D'))
ALTER TABLE [dbo].[SearchSynonym] DROP CONSTRAINT [DF_SearchSynonym_LanguageCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[SeqBatchNumber]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_SeqBatchNumber]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[SeqBatchNumber]', 'U'))
ALTER TABLE [dbo].[SeqBatchNumber] DROP CONSTRAINT [PK_SeqBatchNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[SeqBatchNumber]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Prefix' AND object_id = OBJECT_ID(N'[dbo].[SeqBatchNumber]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_SeqBatchNumber_Prefix]', 'D'))
ALTER TABLE [dbo].[SeqBatchNumber] DROP CONSTRAINT [DF_SeqBatchNumber_Prefix]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipCharge]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ShipCharge]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipCharge]', 'U'))
ALTER TABLE [dbo].[ShipCharge] DROP CONSTRAINT [PK_ShipCharge]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipCharge]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Enable' AND object_id = OBJECT_ID(N'[dbo].[ShipCharge]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipCharge_Enable]', 'D'))
ALTER TABLE [dbo].[ShipCharge] DROP CONSTRAINT [DF_ShipCharge_Enable]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipRate]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ShipRate]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRate]', 'U'))
ALTER TABLE [dbo].[ShipRate] DROP CONSTRAINT [PK_ShipRate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipRate]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PerEach' AND object_id = OBJECT_ID(N'[dbo].[ShipRate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipRate_PerEach]', 'D'))
ALTER TABLE [dbo].[ShipRate] DROP CONSTRAINT [DF_ShipRate_PerEach]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipRule]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ShipRule]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] DROP CONSTRAINT [PK_ShipRule]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipRule]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipRuleType' AND object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipRule_ShipRuleType]', 'D'))
ALTER TABLE [dbo].[ShipRule] DROP CONSTRAINT [DF_ShipRule_ShipRuleType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipVia]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ShipVia]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipVia]', 'U'))
ALTER TABLE [dbo].[ShipVia] DROP CONSTRAINT [PK_ShipVia]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipVia]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[ShipVia]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipVia_Active]', 'D'))
ALTER TABLE [dbo].[ShipVia] DROP CONSTRAINT [DF_ShipVia_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipVia]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Enable' AND object_id = OBJECT_ID(N'[dbo].[ShipVia]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipVia_Enable]', 'D'))
ALTER TABLE [dbo].[ShipVia] DROP CONSTRAINT [DF_ShipVia_Enable]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipVia]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[ShipVia]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipVia_IsDefault]', 'D'))
ALTER TABLE [dbo].[ShipVia] DROP CONSTRAINT [DF_ShipVia_IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipVia]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AllowScheduledShipDate' AND object_id = OBJECT_ID(N'[dbo].[ShipVia]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipVia_AllowScheduledShipDate]', 'D'))
ALTER TABLE [dbo].[ShipVia] DROP CONSTRAINT [DF_ShipVia_AllowScheduledShipDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipmentPackageLine]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_PackageLine]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U'))
ALTER TABLE [dbo].[ShipmentPackageLine] DROP CONSTRAINT [PK_PackageLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipmentPackageLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PackageLineId' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PackageLine_PackageLineId]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] DROP CONSTRAINT [DF_PackageLine_PackageLineId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipmentPackageLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductName' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PackageLine_ProductName]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] DROP CONSTRAINT [DF_PackageLine_ProductName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipmentPackageLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductDescription' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PackageLine_ProductDescription]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] DROP CONSTRAINT [DF_PackageLine_ProductDescription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipmentPackageLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductCode' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PackageLine_ProductCode]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] DROP CONSTRAINT [DF_PackageLine_ProductCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipmentPackageLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QtyOrdered' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PackageLine_QuantityOrdered]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] DROP CONSTRAINT [DF_PackageLine_QuantityOrdered]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipmentPackageLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QtyShipped' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PackageLine_QuantityShipped]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] DROP CONSTRAINT [DF_PackageLine_QuantityShipped]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipmentPackageLine]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Price' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PackageLine_Price]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] DROP CONSTRAINT [DF_PackageLine_Price]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShipmentPackage]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ShipmentPackage]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipmentPackage]', 'U'))
ALTER TABLE [dbo].[ShipmentPackage] DROP CONSTRAINT [PK_ShipmentPackage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Shipment]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Shipment]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Shipment]', 'U'))
ALTER TABLE [dbo].[Shipment] DROP CONSTRAINT [PK_Shipment]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Shipment]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipmentDate' AND object_id = OBJECT_ID(N'[dbo].[Shipment]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Shipment_ShipmentDate]', 'D'))
ALTER TABLE [dbo].[Shipment] DROP CONSTRAINT [DF_Shipment_ShipmentDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShippingClassification]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_ShippingClassification]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ShippingClassification]', 'U'))
ALTER TABLE [dbo].[ShippingClassification] DROP CONSTRAINT [PK_ShippingClassification]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShippingClassification]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShippingClassificationId' AND object_id = OBJECT_ID(N'[dbo].[ShippingClassification]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShippingClassification_ShippingClassificationId]', 'D'))
ALTER TABLE [dbo].[ShippingClassification] DROP CONSTRAINT [DF_ShippingClassification_ShippingClassificationId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShippingClassification]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[ShippingClassification]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShippingClassification_Name]', 'D'))
ALTER TABLE [dbo].[ShippingClassification] DROP CONSTRAINT [DF_ShippingClassification_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShippingClassification]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Classification' AND object_id = OBJECT_ID(N'[dbo].[ShippingClassification]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShippingClassification_Classification]', 'D'))
ALTER TABLE [dbo].[ShippingClassification] DROP CONSTRAINT [DF_ShippingClassification_Classification]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShippingClassification]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[ShippingClassification]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShippingClassification_Description]', 'D'))
ALTER TABLE [dbo].[ShippingClassification] DROP CONSTRAINT [DF_ShippingClassification_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShippingRestriction]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Restriction]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U'))
ALTER TABLE [dbo].[ShippingRestriction] DROP CONSTRAINT [PK_Restriction]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShippingRestriction]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RestrictionId' AND object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Restriction_RestrictionId]', 'D'))
ALTER TABLE [dbo].[ShippingRestriction] DROP CONSTRAINT [DF_Restriction_RestrictionId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShippingRestriction]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Restriction_IsActive]', 'D'))
ALTER TABLE [dbo].[ShippingRestriction] DROP CONSTRAINT [DF_Restriction_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ShippingRestriction]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Restriction_Name]', 'D'))
ALTER TABLE [dbo].[ShippingRestriction] DROP CONSTRAINT [DF_Restriction_Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Specification]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Specification]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Specification]', 'U'))
ALTER TABLE [dbo].[Specification] DROP CONSTRAINT [PK_Specification]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Specification]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Specification]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Specification_Description]', 'D'))
ALTER TABLE [dbo].[Specification] DROP CONSTRAINT [DF_Specification_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Specification]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[Specification]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Specification_Active]', 'D'))
ALTER TABLE [dbo].[Specification] DROP CONSTRAINT [DF_Specification_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[State]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_State]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[State]', 'U'))
ALTER TABLE [dbo].[State] DROP CONSTRAINT [PK_State]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[State]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Taxable' AND object_id = OBJECT_ID(N'[dbo].[State]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_State_Taxable]', 'D'))
ALTER TABLE [dbo].[State] DROP CONSTRAINT [DF_State_Taxable]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[State]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[State]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_State_Active]', 'D'))
ALTER TABLE [dbo].[State] DROP CONSTRAINT [DF_State_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[State]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TaxFreight' AND object_id = OBJECT_ID(N'[dbo].[State]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_State_TaxFreight]', 'D'))
ALTER TABLE [dbo].[State] DROP CONSTRAINT [DF_State_TaxFreight]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[StyleClass]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_StyleClass]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[StyleClass]', 'U'))
ALTER TABLE [dbo].[StyleClass] DROP CONSTRAINT [PK_StyleClass]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[StyleClass]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[StyleClass]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_StyleClass_Description]', 'D'))
ALTER TABLE [dbo].[StyleClass] DROP CONSTRAINT [DF_StyleClass_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[StyleClass]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[StyleClass]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_StyleClass_IsActive]', 'D'))
ALTER TABLE [dbo].[StyleClass] DROP CONSTRAINT [DF_StyleClass_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[StyleTraitValue]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_StyleTraitValue]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[StyleTraitValue]', 'U'))
ALTER TABLE [dbo].[StyleTraitValue] DROP CONSTRAINT [PK_StyleTraitValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[StyleTraitValue]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[StyleTraitValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_StyleTraitValue_IsDefault]', 'D'))
ALTER TABLE [dbo].[StyleTraitValue] DROP CONSTRAINT [DF_StyleTraitValue_IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[StyleTraitValue]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[StyleTraitValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_StyleTraitValue_Description]', 'D'))
ALTER TABLE [dbo].[StyleTraitValue] DROP CONSTRAINT [DF_StyleTraitValue_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[StyleTrait]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_StyleTrait]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[StyleTrait]', 'U'))
ALTER TABLE [dbo].[StyleTrait] DROP CONSTRAINT [PK_StyleTrait]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[StyleTrait]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[StyleTrait]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_StyleTrait_Description]', 'D'))
ALTER TABLE [dbo].[StyleTrait] DROP CONSTRAINT [DF_StyleTrait_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[SubscriptionLine]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_SubscriptionLine]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[SubscriptionLine]', 'U'))
ALTER TABLE [dbo].[SubscriptionLine] DROP CONSTRAINT [PK_SubscriptionLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[SubscriptionProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_SubscriptionProduct]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[SubscriptionProduct]', 'U'))
ALTER TABLE [dbo].[SubscriptionProduct] DROP CONSTRAINT [PK_SubscriptionProduct]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Subscription]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [PK_Subscription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_Active]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FixedPrice' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_FixedPrice]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_FixedPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IncludeInInitialOrder' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_IncludeInInitialOrder]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_IncludeInInitialOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AllMonths' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_AllMonths]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_AllMonths]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'January' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_January]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_January]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'February' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_February]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_February]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'March' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_March]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_March]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'April' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_April]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_April]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'May' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_May]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_May]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'June' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_June]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_June]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'July' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_July]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_July]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'August' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_August]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_August]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'October' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_October]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_October]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'November' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_November]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_November]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Subscription]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'December' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_December]', 'D'))
ALTER TABLE [dbo].[Subscription] DROP CONSTRAINT [DF_Subscription_December]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[TaxExemption]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_TaxExemption]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[TaxExemption]', 'U'))
ALTER TABLE [dbo].[TaxExemption] DROP CONSTRAINT [PK_TaxExemption]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[TaxExemption]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Active' AND object_id = OBJECT_ID(N'[dbo].[TaxExemption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_TaxExemption_Active]', 'D'))
ALTER TABLE [dbo].[TaxExemption] DROP CONSTRAINT [DF_TaxExemption_Active]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[TranslationDictionary]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_TranslationDictionary]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[TranslationDictionary]', 'U'))
ALTER TABLE [dbo].[TranslationDictionary] DROP CONSTRAINT [PK_TranslationDictionary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[TranslationDictionary]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[TranslationDictionary]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_TranslationDictionary_LanguageCode]', 'D'))
ALTER TABLE [dbo].[TranslationDictionary] DROP CONSTRAINT [DF_TranslationDictionary_LanguageCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[TranslationProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_TranslationProperty]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[TranslationProperty]', 'U'))
ALTER TABLE [dbo].[TranslationProperty] DROP CONSTRAINT [PK_TranslationProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[TranslationProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[TranslationProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_TranslationProperty_LanguageCode]', 'D'))
ALTER TABLE [dbo].[TranslationProperty] DROP CONSTRAINT [DF_TranslationProperty_LanguageCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[TranslationProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TranslatedValue' AND object_id = OBJECT_ID(N'[dbo].[TranslationProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_TranslationProperty_TranslatedValue]', 'D'))
ALTER TABLE [dbo].[TranslationProperty] DROP CONSTRAINT [DF_TranslationProperty_TranslatedValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfilePassword]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_UserProfilePassword]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfilePassword]', 'U'))
ALTER TABLE [dbo].[UserProfilePassword] DROP CONSTRAINT [PK_UserProfilePassword]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfilePassword]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'UserProfilePasswordId' AND object_id = OBJECT_ID(N'[dbo].[UserProfilePassword]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfilePassword_UserProfilePasswordId]', 'D'))
ALTER TABLE [dbo].[UserProfilePassword] DROP CONSTRAINT [DF_UserProfilePassword_UserProfilePasswordId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfileProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_UserProfileProperty]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfileProperty]', 'U'))
ALTER TABLE [dbo].[UserProfileProperty] DROP CONSTRAINT [PK_UserProfileProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_UserProfile]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [PK_UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CanChangePassword' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_CanChangePassword]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_CanChangePassword]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CanSubmitOrder' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_CanSubmitOrder]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_CanSubmitOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CanViewAllOrders' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_CanViewAllOrders]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_CanViewAllOrders]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsSubscribed' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_IsSubscribed]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_IsSubscribed]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ApplicationName' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_ApplicationName]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_ApplicationName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_LanguageCode]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_LanguageCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionUser' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_SubscriptionUser]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_SubscriptionUser]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsGuest' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_IsGuest]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_IsGuest]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsReviewingContent' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_IsReviewingContent]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_IsReviewingContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LimitExceededNotification' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_LimitExceededNotification]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_LimitExceededNotification]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsEditingContent' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_IsEditingContent]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_IsEditingContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DashboardIsHomepage' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_DashboardIsHomepage]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_DashboardIsHomepage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPasswordChangeRequired' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_IsPasswordChangeRequired]', 'D'))
ALTER TABLE [dbo].[UserProfile] DROP CONSTRAINT [DF_UserProfile_IsPasswordChangeRequired]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Vendor]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Vendor]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Vendor]', 'U'))
ALTER TABLE [dbo].[Vendor] DROP CONSTRAINT [PK_Vendor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Warehouse]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_Warehouse]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[Warehouse]', 'U'))
ALTER TABLE [dbo].[Warehouse] DROP CONSTRAINT [PK_Warehouse]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[Warehouse]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UC_Warehouse]', 'UQ') AND parent_object_id = OBJECT_ID(N'[dbo].[Warehouse]', 'U'))
ALTER TABLE [dbo].[Warehouse] DROP CONSTRAINT [UC_Warehouse]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebPageContent]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_WebPageContent]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[WebPageContent]', 'U'))
ALTER TABLE [dbo].[WebPageContent] DROP CONSTRAINT [PK_WebPageContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebPageContent]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OverrideParent' AND object_id = OBJECT_ID(N'[dbo].[WebPageContent]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebPageContent_OverrideParent]', 'D'))
ALTER TABLE [dbo].[WebPageContent] DROP CONSTRAINT [DF_WebPageContent_OverrideParent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebPage]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_WebPage]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[WebPage]', 'U'))
ALTER TABLE [dbo].[WebPage] DROP CONSTRAINT [PK_WebPage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSiteConfiguration]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_WebSiteConfiguration]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteConfiguration]', 'U'))
ALTER TABLE [dbo].[WebSiteConfiguration] DROP CONSTRAINT [PK_WebSiteConfiguration]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSiteCurrency]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_WebSiteCurrency]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCurrency]', 'U'))
ALTER TABLE [dbo].[WebSiteCurrency] DROP CONSTRAINT [PK_WebSiteCurrency]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSiteCurrency]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsLive' AND object_id = OBJECT_ID(N'[dbo].[WebSiteCurrency]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSiteCurrency_IsLive]', 'D'))
ALTER TABLE [dbo].[WebSiteCurrency] DROP CONSTRAINT [DF_WebSiteCurrency_IsLive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSiteCurrency]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[WebSiteCurrency]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSiteCurrency_IsDefault]', 'D'))
ALTER TABLE [dbo].[WebSiteCurrency] DROP CONSTRAINT [DF_WebSiteCurrency_IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSiteLanguage]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_WebSiteLangauge]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteLanguage]', 'U'))
ALTER TABLE [dbo].[WebSiteLanguage] DROP CONSTRAINT [PK_WebSiteLangauge]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSiteLanguage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[WebSiteLanguage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSiteLanguage_IsDefault]', 'D'))
ALTER TABLE [dbo].[WebSiteLanguage] DROP CONSTRAINT [DF_WebSiteLanguage_IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSiteLanguage]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsLive' AND object_id = OBJECT_ID(N'[dbo].[WebSiteLanguage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSiteLanguage_IsLive]', 'D'))
ALTER TABLE [dbo].[WebSiteLanguage] DROP CONSTRAINT [DF_WebSiteLanguage_IsLive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK_WebSite]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [PK_WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TopContent' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_TopContent]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_TopContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShowTopContent' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_ShowTopContent]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_ShowTopContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LeftContent' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_LeftContent]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_LeftContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShowLeftContent' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_ShowLeftContent]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_ShowLeftContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RightContent' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_RightContent]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_RightContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShowRightContent' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_ShowRightContent]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_ShowRightContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BottomContent' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_BottomContent]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_BottomContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShowBottomContent' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_ShowBottomContent]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_ShowBottomContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OpeningPageTags' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_OpeningPageTags]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_OpeningPageTags]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ClosingPageTags' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_ClosingPageTags]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_ClosingPageTags]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Title' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_Title]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_Title]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HeaderContent' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_HeaderContent]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_HeaderContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BodyStyle' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_BodyTags]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_BodyTags]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'StyleSheet' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_StyleSheet]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_StyleSheet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'JavaScript' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_JavaScript]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_JavaScript]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ERPServiceUrl' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_ERPServiceUrl]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_ERPServiceUrl]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ERPServiceTimeout' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_ERPServiceTimeout]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_ERPServiceTimeout]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TermsOfUse' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_TermsOfUse]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_TermsOfUse]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HostCompanyName' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_HostCompanyName]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_HostCompanyName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_Description]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DomainName' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_DomainName]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_DomainName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MapProductsToCategories' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_MapProductsToCategories]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_MapProductsToCategories]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AllowMultiplePromotions' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_AllowMultiplePromotions]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_AllowMultiplePromotions]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_IsActive]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsRestricted' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_IsRestricted]', 'D'))
ALTER TABLE [dbo].[WebSite] DROP CONSTRAINT [DF_WebSite_IsRestricted]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WishListProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK__WishListProduct__4F089A18]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[WishListProduct]', 'U'))
ALTER TABLE [dbo].[WishListProduct] DROP CONSTRAINT [PK__WishListProduct__4F089A18]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WishListProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IX_WishListProductId_ProductId_uk]', 'UQ') AND parent_object_id = OBJECT_ID(N'[dbo].[WishListProduct]', 'U'))
ALTER TABLE [dbo].[WishListProduct] DROP CONSTRAINT [IX_WishListProductId_ProductId_uk]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[WishListProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QtyOrdered' AND object_id = OBJECT_ID(N'[dbo].[WishListProduct]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WishListProduct_QtyOrdered]', 'D'))
ALTER TABLE [dbo].[WishListProduct] DROP CONSTRAINT [DF_WishListProduct_QtyOrdered]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_Applications]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK__aspnet_Applicati__2645B050]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Applications]', 'U'))
ALTER TABLE [dbo].[aspnet_Applications] DROP CONSTRAINT [PK__aspnet_Applicati__2645B050]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_Applications]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ApplicationId' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Applications]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_aspnet_Applications_ApplicationId]', 'D'))
ALTER TABLE [dbo].[aspnet_Applications] DROP CONSTRAINT [DF_aspnet_Applications_ApplicationId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_Paths]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK__aspnet_Paths__6CD828CA]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Paths]', 'U'))
ALTER TABLE [dbo].[aspnet_Paths] DROP CONSTRAINT [PK__aspnet_Paths__6CD828CA]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_Paths]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PathId' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Paths]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_aspnet_Paths_PathId]', 'D'))
ALTER TABLE [dbo].[aspnet_Paths] DROP CONSTRAINT [DF_aspnet_Paths_PathId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_PersonalizationPerUser]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK__aspnet_Personali__756D6ECB]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser]', 'U'))
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] DROP CONSTRAINT [PK__aspnet_Personali__756D6ECB]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_PersonalizationPerUser]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_aspnet_PersonalizationPerUser_Id]', 'D'))
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] DROP CONSTRAINT [DF_aspnet_PersonalizationPerUser_Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_Roles]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK__aspnet_Roles__59C55456]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Roles]', 'U'))
ALTER TABLE [dbo].[aspnet_Roles] DROP CONSTRAINT [PK__aspnet_Roles__59C55456]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_Roles]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RoleId' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Roles]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_aspnet_Roles_RoleId]', 'D'))
ALTER TABLE [dbo].[aspnet_Roles] DROP CONSTRAINT [DF_aspnet_Roles_RoleId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_Users]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PK__aspnet_Users__2B0A656D]', 'PK') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Users]', 'U'))
ALTER TABLE [dbo].[aspnet_Users] DROP CONSTRAINT [PK__aspnet_Users__2B0A656D]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_Users]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'UserId' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Users]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_aspnet_Users_UserId]', 'D'))
ALTER TABLE [dbo].[aspnet_Users] DROP CONSTRAINT [DF_aspnet_Users_UserId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_Users]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MobileAlias' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Users]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_aspnet_Users_MobileAlias]', 'D'))
ALTER TABLE [dbo].[aspnet_Users] DROP CONSTRAINT [DF_aspnet_Users_MobileAlias]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_Users]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsAnonymous' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Users]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_aspnet_Users_IsAnonymous]', 'D'))
ALTER TABLE [dbo].[aspnet_Users] DROP CONSTRAINT [DF_aspnet_Users_IsAnonymous]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_qty1' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_brk_qty1]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_brk_qty1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_qty2' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_brk_qty2]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_brk_qty2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_qty3' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_brk_qty3]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_brk_qty3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_qty4' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_brk_qty4]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_brk_qty4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_qty5' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_brk_qty5]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_brk_qty5]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_price1' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_brk_price1]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_brk_price1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_price2' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_brk_price2]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_brk_price2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_price3' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_brk_price3]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_brk_price3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_price4' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_brk_price4]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_brk_price4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_price5' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_brk_price5]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_brk_price5]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'dol_percent1' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_dol_percent1]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_dol_percent1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'dol_percent2' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_dol_percent2]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_dol_percent2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'dol_percent3' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_dol_percent3]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_dol_percent3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'dol_percent4' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_dol_percent4]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_dol_percent4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'dol_percent5' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_dol_percent5]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_dol_percent5]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemCustPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'cust_item_seq' AND object_id = OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemCustPrice_Batch_cust_item_seq]', 'D'))
ALTER TABLE [dbo].[ItemCustPrice_Batch] DROP CONSTRAINT [DF_ItemCustPrice_Batch_cust_item_seq]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'unit_price1' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_unit_price1]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_unit_price1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'unit_price2' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_unit_price2]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_unit_price2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'unit_price3' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_unit_price3]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_unit_price3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'unit_price4' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_unit_price4]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_unit_price4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'unit_price5' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_unit_price5]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_unit_price5]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'unit_price6' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_unit_price6]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_unit_price6]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'reprice' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_reprice]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_reprice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_qty1' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_brk_qty1]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_brk_qty1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_qty2' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_brk_qty2]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_brk_qty2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_qty3' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_brk_qty3]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_brk_qty3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_qty4' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_brk_qty4]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_brk_qty4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_qty5' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_brk_qty5]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_brk_qty5]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_price1' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_brk_price1]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_brk_price1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_price2' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_brk_price2]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_brk_price2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_price3' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_brk_price3]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_brk_price3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_price4' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_brk_price4]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_brk_price4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'brk_price5' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_brk_price5]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_brk_price5]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'base_code1' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_base_code1]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_base_code1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'base_code2' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_base_code2]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_base_code2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'base_code3' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_base_code3]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_base_code3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'base_code4' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_base_code4]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_base_code4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'base_code5' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_base_code5]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_base_code5]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'dol_percent1' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_dol_percent1]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_dol_percent1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'dol_percent2' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_dol_percent2]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_dol_percent2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'dol_percent3' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_dol_percent3]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_dol_percent3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'dol_percent4' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_dol_percent4]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_dol_percent4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[ItemPrice_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'dol_percent5' AND object_id = OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ItemPrice_Batch_dol_percent5]', 'D'))
ALTER TABLE [dbo].[ItemPrice_Batch] DROP CONSTRAINT [DF_ItemPrice_Batch_dol_percent5]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[aspnet_Membership]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PasswordFormat' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Membership]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_aspnet_Membership_PasswordFormat]', 'D'))
ALTER TABLE [dbo].[aspnet_Membership] DROP CONSTRAINT [DF_aspnet_Membership_PasswordFormat]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping constraints from [dbo].[tmp_PriceData]'
GO
IF EXISTS (SELECT 1 FROM sys.columns WHERE name = N'tmp_PriceDataId' AND object_id = OBJECT_ID(N'[dbo].[tmp_PriceData]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_tmp_PriceData_tmp_PriceDataID]', 'D'))
ALTER TABLE [dbo].[tmp_PriceData] DROP CONSTRAINT [DF_tmp_PriceData_tmp_PriceDataID]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ApplicationDictionary] from [dbo].[ApplicationDictionary]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ApplicationDictionary' AND object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]'))
DROP INDEX [IX_ApplicationDictionary] ON [dbo].[ApplicationDictionary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ApplicationLog_LogDate] from [dbo].[ApplicationLog]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ApplicationLog_LogDate' AND object_id = OBJECT_ID(N'[dbo].[ApplicationLog]'))
DROP INDEX [IX_ApplicationLog_LogDate] ON [dbo].[ApplicationLog]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ApplicationMessage_Name] from [dbo].[ApplicationMessage]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ApplicationMessage_Name' AND object_id = OBJECT_ID(N'[dbo].[ApplicationMessage]'))
DROP INDEX [IX_ApplicationMessage_Name] ON [dbo].[ApplicationMessage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ApplicationSetting_Name] from [dbo].[ApplicationSetting]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ApplicationSetting_Name' AND object_id = OBJECT_ID(N'[dbo].[ApplicationSetting]'))
DROP INDEX [IX_ApplicationSetting_Name] ON [dbo].[ApplicationSetting]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_FilterSection] from [dbo].[AttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_FilterSection' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]'))
DROP INDEX [IX_FilterSection] ON [dbo].[AttributeType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_FilterValue] from [dbo].[AttributeValue]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_FilterValue' AND object_id = OBJECT_ID(N'[dbo].[AttributeValue]'))
DROP INDEX [IX_FilterValue] ON [dbo].[AttributeValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_BudgetCalendar_Customer_FiscalYear] from [dbo].[BudgetCalendar]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_BudgetCalendar_Customer_FiscalYear' AND object_id = OBJECT_ID(N'[dbo].[BudgetCalendar]'))
DROP INDEX [IX_BudgetCalendar_Customer_FiscalYear] ON [dbo].[BudgetCalendar]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Carrier_Name] from [dbo].[Carrier]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Carrier_Name' AND object_id = OBJECT_ID(N'[dbo].[Carrier]'))
DROP INDEX [IX_Carrier_Name] ON [dbo].[Carrier]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CategoryFilterSection] from [dbo].[CategoryAttributeType]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CategoryFilterSection' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]'))
DROP INDEX [IX_CategoryFilterSection] ON [dbo].[CategoryAttributeType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CategoryProperty] from [dbo].[CategoryProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CategoryProperty' AND object_id = OBJECT_ID(N'[dbo].[CategoryProperty]'))
DROP INDEX [IX_CategoryProperty] ON [dbo].[CategoryProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Category] from [dbo].[Category]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Category' AND object_id = OBJECT_ID(N'[dbo].[Category]'))
DROP INDEX [IX_Category] ON [dbo].[Category]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Company] from [dbo].[Company]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Company' AND object_id = OBJECT_ID(N'[dbo].[Company]'))
DROP INDEX [IX_Company] ON [dbo].[Company]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ConfigurationOptionCondition_ConfigurationOptionId_Sequence] from [dbo].[ConfigurationOptionCondition]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ConfigurationOptionCondition_ConfigurationOptionId_Sequence' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOptionCondition]'))
DROP INDEX [IX_ConfigurationOptionCondition_ConfigurationOptionId_Sequence] ON [dbo].[ConfigurationOptionCondition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ConfigurationOption_ConfigurationPageId_Name] from [dbo].[ConfigurationOption]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ConfigurationOption_ConfigurationPageId_Name' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]'))
DROP INDEX [IX_ConfigurationOption_ConfigurationPageId_Name] ON [dbo].[ConfigurationOption]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Configuration] from [dbo].[Configuration]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Configuration' AND object_id = OBJECT_ID(N'[dbo].[Configuration]'))
DROP INDEX [IX_Configuration] ON [dbo].[Configuration]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ContentItemField_ContentKeyPublishOn] from [dbo].[ContentItemField]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ContentItemField_ContentKeyPublishOn' AND object_id = OBJECT_ID(N'[dbo].[ContentItemField]'))
DROP INDEX [IX_ContentItemField_ContentKeyPublishOn] ON [dbo].[ContentItemField]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [_dta_index_Content_9_1092914965__K2_5] from [dbo].[Content]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'_dta_index_Content_9_1092914965__K2_5' AND object_id = OBJECT_ID(N'[dbo].[Content]'))
DROP INDEX [_dta_index_Content_9_1092914965__K2_5] ON [dbo].[Content]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CreditCardTransaction_AuthCode] from [dbo].[CreditCardTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CreditCardTransaction_AuthCode' AND object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]'))
DROP INDEX [IX_CreditCardTransaction_AuthCode] ON [dbo].[CreditCardTransaction]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CreditCardTransaction_ShipmentNumber] from [dbo].[CreditCardTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CreditCardTransaction_ShipmentNumber' AND object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]'))
DROP INDEX [IX_CreditCardTransaction_ShipmentNumber] ON [dbo].[CreditCardTransaction]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CustomProperty] from [dbo].[CustomProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomProperty' AND object_id = OBJECT_ID(N'[dbo].[CustomProperty]'))
DROP INDEX [IX_CustomProperty] ON [dbo].[CustomProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CustomerBudget_Customer_ShipToCustomer_UserProfile_FiscalYear] from [dbo].[CustomerBudget]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerBudget_Customer_ShipToCustomer_UserProfile_FiscalYear' AND object_id = OBJECT_ID(N'[dbo].[CustomerBudget]'))
DROP INDEX [IX_CustomerBudget_Customer_ShipToCustomer_UserProfile_FiscalYear] ON [dbo].[CustomerBudget]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CustomerOrderProperty_Name] from [dbo].[CustomerOrderProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerOrderProperty_Name' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrderProperty]'))
DROP INDEX [IX_CustomerOrderProperty_Name] ON [dbo].[CustomerOrderProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Order_CustomerNumber] from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Order_CustomerNumber' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]'))
DROP INDEX [IX_Order_CustomerNumber] ON [dbo].[CustomerOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CustomerOrder_CustomerId] from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerOrder_CustomerId' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]'))
DROP INDEX [IX_CustomerOrder_CustomerId] ON [dbo].[CustomerOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Order_OrderNumber] from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Order_OrderNumber' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]'))
DROP INDEX [IX_Order_OrderNumber] ON [dbo].[CustomerOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Order_Status] from [dbo].[CustomerOrder]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Order_Status' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]'))
DROP INDEX [IX_Order_Status] ON [dbo].[CustomerOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CustomerProductPrice_Customer_Product] from [dbo].[CustomerProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerProductPrice_Customer_Product' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductPrice]'))
DROP INDEX [IX_CustomerProductPrice_Customer_Product] ON [dbo].[CustomerProductPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CustomerProductSet_CustomerId] from [dbo].[CustomerProductSet]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerProductSet_CustomerId' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]'))
DROP INDEX [IX_CustomerProductSet_CustomerId] ON [dbo].[CustomerProductSet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CustomerProduct] from [dbo].[CustomerProduct]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerProduct' AND object_id = OBJECT_ID(N'[dbo].[CustomerProduct]'))
DROP INDEX [IX_CustomerProduct] ON [dbo].[CustomerProduct]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_CustomerProperty] from [dbo].[CustomerProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerProperty' AND object_id = OBJECT_ID(N'[dbo].[CustomerProperty]'))
DROP INDEX [IX_CustomerProperty] ON [dbo].[CustomerProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Customer_CustomerNumber] from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Customer_CustomerNumber' AND object_id = OBJECT_ID(N'[dbo].[Customer]'))
DROP INDEX [IX_Customer_CustomerNumber] ON [dbo].[Customer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Customer_ParentId] from [dbo].[Customer]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Customer_ParentId' AND object_id = OBJECT_ID(N'[dbo].[Customer]'))
DROP INDEX [IX_Customer_ParentId] ON [dbo].[Customer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_DictionaryLabel] from [dbo].[DictionaryLabel]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_DictionaryLabel' AND object_id = OBJECT_ID(N'[dbo].[DictionaryLabel]'))
DROP INDEX [IX_DictionaryLabel] ON [dbo].[DictionaryLabel]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_GiftCard] from [dbo].[GiftCard]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_GiftCard' AND object_id = OBJECT_ID(N'[dbo].[GiftCard]'))
DROP INDEX [IX_GiftCard] ON [dbo].[GiftCard]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_IntegrationConnection_Name] from [dbo].[IntegrationConnection]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationConnection_Name' AND object_id = OBJECT_ID(N'[dbo].[IntegrationConnection]'))
DROP INDEX [IX_IntegrationConnection_Name] ON [dbo].[IntegrationConnection]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_IntegrationJob] from [dbo].[IntegrationJobLog]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJob' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJobLog]'))
DROP INDEX [IX_IntegrationJob] ON [dbo].[IntegrationJobLog]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_IntegrationJobParameter_StepParameter] from [dbo].[IntegrationJobParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJobParameter_StepParameter' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJobParameter]'))
DROP INDEX [IX_IntegrationJobParameter_StepParameter] ON [dbo].[IntegrationJobParameter]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_IntegrationJob_StartDateTime] from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJob_StartDateTime' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]'))
DROP INDEX [IX_IntegrationJob_StartDateTime] ON [dbo].[IntegrationJob]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_IntegrationJob_StartDateTime_IsRealTime_ScheduleDateTime] from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJob_StartDateTime_IsRealTime_ScheduleDateTime' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]'))
DROP INDEX [IX_IntegrationJob_StartDateTime_IsRealTime_ScheduleDateTime] ON [dbo].[IntegrationJob]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_IntegrationJob_JobDefinition] from [dbo].[IntegrationJob]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJob_JobDefinition' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]'))
DROP INDEX [IX_IntegrationJob_JobDefinition] ON [dbo].[IntegrationJob]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_InventoryTransaction] from [dbo].[InventoryTransaction]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_InventoryTransaction' AND object_id = OBJECT_ID(N'[dbo].[InventoryTransaction]'))
DROP INDEX [IX_InventoryTransaction] ON [dbo].[InventoryTransaction]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_InvoiceHistoryLine_SearchColumns] from [dbo].[InvoiceHistoryLine]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_InvoiceHistoryLine_SearchColumns' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistoryLine]'))
DROP INDEX [IX_InvoiceHistoryLine_SearchColumns] ON [dbo].[InvoiceHistoryLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_InvoiceHistory_SearchColumns] from [dbo].[InvoiceHistory]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_InvoiceHistory_SearchColumns' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistory]'))
DROP INDEX [IX_InvoiceHistory_SearchColumns] ON [dbo].[InvoiceHistory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_InvoiceLine_InvoiceId] from [dbo].[InvoiceLine]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_InvoiceLine_InvoiceId' AND object_id = OBJECT_ID(N'[dbo].[InvoiceLine]'))
DROP INDEX [IX_InvoiceLine_InvoiceId] ON [dbo].[InvoiceLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Invoice_CustomerId] from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Invoice_CustomerId' AND object_id = OBJECT_ID(N'[dbo].[Invoice]'))
DROP INDEX [IX_Invoice_CustomerId] ON [dbo].[Invoice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Invoice_OrderNumber] from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Invoice_OrderNumber' AND object_id = OBJECT_ID(N'[dbo].[Invoice]'))
DROP INDEX [IX_Invoice_OrderNumber] ON [dbo].[Invoice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Invoice_InvoiceNumber] from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Invoice_InvoiceNumber' AND object_id = OBJECT_ID(N'[dbo].[Invoice]'))
DROP INDEX [IX_Invoice_InvoiceNumber] ON [dbo].[Invoice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Invoice_ShipToId] from [dbo].[Invoice]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Invoice_ShipToId' AND object_id = OBJECT_ID(N'[dbo].[Invoice]'))
DROP INDEX [IX_Invoice_ShipToId] ON [dbo].[Invoice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_IntegrationJobDefinitionPostprocessorParameter_Name] from [dbo].[JobDefinitionParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJobDefinitionPostprocessorParameter_Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]'))
DROP INDEX [IX_IntegrationJobDefinitionPostprocessorParameter_Name] ON [dbo].[JobDefinitionParameter]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_IntegrationJobDefinitionStepFieldMap] from [dbo].[JobDefinitionStepFieldMap]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJobDefinitionStepFieldMap' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]'))
DROP INDEX [IX_IntegrationJobDefinitionStepFieldMap] ON [dbo].[JobDefinitionStepFieldMap]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_IntegrationJobDefinitionStepParameter_Name] from [dbo].[JobDefinitionStepParameter]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJobDefinitionStepParameter_Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]'))
DROP INDEX [IX_IntegrationJobDefinitionStepParameter_Name] ON [dbo].[JobDefinitionStepParameter]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_IntegrationJobDefinitionStep_Sequence] from [dbo].[JobDefinitionStep]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJobDefinitionStep_Sequence' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]'))
DROP INDEX [IX_IntegrationJobDefinitionStep_Sequence] ON [dbo].[JobDefinitionStep]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_IntegrationJobDefinition_Name] from [dbo].[JobDefinition]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJobDefinition_Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]'))
DROP INDEX [IX_IntegrationJobDefinition_Name] ON [dbo].[JobDefinition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Language_LanguageCode] from [dbo].[Language]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Language_LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[Language]'))
DROP INDEX [IX_Language_LanguageCode] ON [dbo].[Language]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_LocalizedTaxRateByPostalCode] from [dbo].[LocalTaxRate]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_LocalizedTaxRateByPostalCode' AND object_id = OBJECT_ID(N'[dbo].[LocalTaxRate]'))
DROP INDEX [IX_LocalizedTaxRateByPostalCode] ON [dbo].[LocalTaxRate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_MessageStatus_Message_UserProfile] from [dbo].[MessageStatus]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_MessageStatus_Message_UserProfile' AND object_id = OBJECT_ID(N'[dbo].[MessageStatus]'))
DROP INDEX [IX_MessageStatus_Message_UserProfile] ON [dbo].[MessageStatus]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_MessageTarget_TargetType_TargetKey] from [dbo].[MessageTarget]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_MessageTarget_TargetType_TargetKey' AND object_id = OBJECT_ID(N'[dbo].[MessageTarget]'))
DROP INDEX [IX_MessageTarget_TargetType_TargetKey] ON [dbo].[MessageTarget]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Message_Subject_DateToDisplay] from [dbo].[Message]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Message_Subject_DateToDisplay' AND object_id = OBJECT_ID(N'[dbo].[Message]'))
DROP INDEX [IX_Message_Subject_DateToDisplay] ON [dbo].[Message]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_MiscellaneousCode] from [dbo].[MiscellaneousCode]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_MiscellaneousCode' AND object_id = OBJECT_ID(N'[dbo].[MiscellaneousCode]'))
DROP INDEX [IX_MiscellaneousCode] ON [dbo].[MiscellaneousCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_OrderHistoryLine_OrderHistory] from [dbo].[OrderHistoryLine]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderHistoryLine_OrderHistory' AND object_id = OBJECT_ID(N'[dbo].[OrderHistoryLine]'))
DROP INDEX [IX_OrderHistoryLine_OrderHistory] ON [dbo].[OrderHistoryLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_OrderHistoryLine_ProductERPNumber] from [dbo].[OrderHistoryLine]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderHistoryLine_ProductERPNumber' AND object_id = OBJECT_ID(N'[dbo].[OrderHistoryLine]'))
DROP INDEX [IX_OrderHistoryLine_ProductERPNumber] ON [dbo].[OrderHistoryLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_OrderHistory_SearchColumns] from [dbo].[OrderHistory]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderHistory_SearchColumns' AND object_id = OBJECT_ID(N'[dbo].[OrderHistory]'))
DROP INDEX [IX_OrderHistory_SearchColumns] ON [dbo].[OrderHistory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_OrderHistory_ERPOrderNumber] from [dbo].[OrderHistory]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderHistory_ERPOrderNumber' AND object_id = OBJECT_ID(N'[dbo].[OrderHistory]'))
DROP INDEX [IX_OrderHistory_ERPOrderNumber] ON [dbo].[OrderHistory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_OrderLineAttribute] from [dbo].[OrderLineProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderLineAttribute' AND object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]'))
DROP INDEX [IX_OrderLineAttribute] ON [dbo].[OrderLineProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_OrderLine_Line] from [dbo].[OrderLine]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderLine_Line' AND object_id = OBJECT_ID(N'[dbo].[OrderLine]'))
DROP INDEX [IX_OrderLine_Line] ON [dbo].[OrderLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Persona_Name] from [dbo].[Persona]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Persona_Name' AND object_id = OBJECT_ID(N'[dbo].[Persona]'))
DROP INDEX [IX_Persona_Name] ON [dbo].[Persona]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Plugin] from [dbo].[Plugin]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Plugin' AND object_id = OBJECT_ID(N'[dbo].[Plugin]'))
DROP INDEX [IX_Plugin] ON [dbo].[Plugin]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_PriceMatrix] from [dbo].[PriceMatrix]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PriceMatrix' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix]'))
DROP INDEX [IX_PriceMatrix] ON [dbo].[PriceMatrix]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_PriceMatrix_Batch] from [dbo].[PriceMatrix_Batch]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PriceMatrix_Batch' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix_Batch]'))
DROP INDEX [IX_PriceMatrix_Batch] ON [dbo].[PriceMatrix_Batch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ProductPrice_ProductId] from [dbo].[ProductPrice]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ProductPrice_ProductId' AND object_id = OBJECT_ID(N'[dbo].[ProductPrice]'))
DROP INDEX [IX_ProductPrice_ProductId] ON [dbo].[ProductPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ProductProperty] from [dbo].[ProductProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ProductProperty' AND object_id = OBJECT_ID(N'[dbo].[ProductProperty]'))
DROP INDEX [IX_ProductProperty] ON [dbo].[ProductProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ProductUnitOfMeasure_ProductIdUnitOfMeasure] from [dbo].[ProductUnitOfMeasure]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ProductUnitOfMeasure_ProductIdUnitOfMeasure' AND object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]'))
DROP INDEX [IX_ProductUnitOfMeasure_ProductIdUnitOfMeasure] ON [dbo].[ProductUnitOfMeasure]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ProductWarehouse_ProductIdWarehouseId] from [dbo].[ProductWarehouse]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ProductWarehouse_ProductIdWarehouseId' AND object_id = OBJECT_ID(N'[dbo].[ProductWarehouse]'))
DROP INDEX [IX_ProductWarehouse_ProductIdWarehouseId] ON [dbo].[ProductWarehouse]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Product_ERPNumber] from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Product_ERPNumber' AND object_id = OBJECT_ID(N'[dbo].[Product]'))
DROP INDEX [IX_Product_ERPNumber] ON [dbo].[Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Product] from [dbo].[Product]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Product' AND object_id = OBJECT_ID(N'[dbo].[Product]'))
DROP INDEX [IX_Product] ON [dbo].[Product]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_RuleTypeOption_RuleTypeId] from [dbo].[RuleTypeOption]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_RuleTypeOption_RuleTypeId' AND object_id = OBJECT_ID(N'[dbo].[RuleTypeOption]'))
DROP INDEX [IX_RuleTypeOption_RuleTypeId] ON [dbo].[RuleTypeOption]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_RuleType_Name] from [dbo].[RuleType]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_RuleType_Name' AND object_id = OBJECT_ID(N'[dbo].[RuleType]'))
DROP INDEX [IX_RuleType_Name] ON [dbo].[RuleType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_SalesmanNumber] from [dbo].[Salesperson]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_SalesmanNumber' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]'))
DROP INDEX [IX_SalesmanNumber] ON [dbo].[Salesperson]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ShipVia_Carrier_ShipCode] from [dbo].[ShipVia]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ShipVia_Carrier_ShipCode' AND object_id = OBJECT_ID(N'[dbo].[ShipVia]'))
DROP INDEX [IX_ShipVia_Carrier_ShipCode] ON [dbo].[ShipVia]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_PackageLine_OrderLineId] from [dbo].[ShipmentPackageLine]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PackageLine_OrderLineId' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]'))
DROP INDEX [IX_PackageLine_OrderLineId] ON [dbo].[ShipmentPackageLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_PackageLine_ShipmentPackageId] from [dbo].[ShipmentPackageLine]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PackageLine_ShipmentPackageId' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]'))
DROP INDEX [IX_PackageLine_ShipmentPackageId] ON [dbo].[ShipmentPackageLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ShipmentPackage_ShipmentId] from [dbo].[ShipmentPackage]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ShipmentPackage_ShipmentId' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackage]'))
DROP INDEX [IX_ShipmentPackage_ShipmentId] ON [dbo].[ShipmentPackage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Shipment_ShipmentNumber] from [dbo].[Shipment]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Shipment_ShipmentNumber' AND object_id = OBJECT_ID(N'[dbo].[Shipment]'))
DROP INDEX [IX_Shipment_ShipmentNumber] ON [dbo].[Shipment]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_ShippingClassification_Classification] from [dbo].[ShippingClassification]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ShippingClassification_Classification' AND object_id = OBJECT_ID(N'[dbo].[ShippingClassification]'))
DROP INDEX [IX_ShippingClassification_Classification] ON [dbo].[ShippingClassification]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [_dta_index_Specification_9_1752393312__K3_K1] from [dbo].[Specification]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'_dta_index_Specification_9_1752393312__K3_K1' AND object_id = OBJECT_ID(N'[dbo].[Specification]'))
DROP INDEX [_dta_index_Specification_9_1752393312__K3_K1] ON [dbo].[Specification]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Abbreviation] from [dbo].[State]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Abbreviation' AND object_id = OBJECT_ID(N'[dbo].[State]'))
DROP INDEX [IX_Abbreviation] ON [dbo].[State]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_StyleClass_Name] from [dbo].[StyleClass]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_StyleClass_Name' AND object_id = OBJECT_ID(N'[dbo].[StyleClass]'))
DROP INDEX [IX_StyleClass_Name] ON [dbo].[StyleClass]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_StyleTraitValue_Value] from [dbo].[StyleTraitValue]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_StyleTraitValue_Value' AND object_id = OBJECT_ID(N'[dbo].[StyleTraitValue]'))
DROP INDEX [IX_StyleTraitValue_Value] ON [dbo].[StyleTraitValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_StyleTrait_Name] from [dbo].[StyleTrait]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_StyleTrait_Name' AND object_id = OBJECT_ID(N'[dbo].[StyleTrait]'))
DROP INDEX [IX_StyleTrait_Name] ON [dbo].[StyleTrait]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_TranslationDictionary_SourceKeywordLanguageCode] from [dbo].[TranslationDictionary]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_TranslationDictionary_SourceKeywordLanguageCode' AND object_id = OBJECT_ID(N'[dbo].[TranslationDictionary]'))
DROP INDEX [IX_TranslationDictionary_SourceKeywordLanguageCode] ON [dbo].[TranslationDictionary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_TranslationProperty_LanguageCode] from [dbo].[TranslationProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_TranslationProperty_LanguageCode' AND object_id = OBJECT_ID(N'[dbo].[TranslationProperty]'))
DROP INDEX [IX_TranslationProperty_LanguageCode] ON [dbo].[TranslationProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_TranslationProperty_ParentTable] from [dbo].[TranslationProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_TranslationProperty_ParentTable' AND object_id = OBJECT_ID(N'[dbo].[TranslationProperty]'))
DROP INDEX [IX_TranslationProperty_ParentTable] ON [dbo].[TranslationProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_TranslationProperty_ParentNameLanguageCode] from [dbo].[TranslationProperty]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_TranslationProperty_ParentNameLanguageCode' AND object_id = OBJECT_ID(N'[dbo].[TranslationProperty]'))
DROP INDEX [IX_TranslationProperty_ParentNameLanguageCode] ON [dbo].[TranslationProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_UserProfile] from [dbo].[UserProfile]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_UserProfile' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]'))
DROP INDEX [IX_UserProfile] ON [dbo].[UserProfile]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_Vendor_VendorNumber] from [dbo].[Vendor]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Vendor_VendorNumber' AND object_id = OBJECT_ID(N'[dbo].[Vendor]'))
DROP INDEX [IX_Vendor_VendorNumber] ON [dbo].[Vendor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [IX_WebSite] from [dbo].[WebSite]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_WebSite' AND object_id = OBJECT_ID(N'[dbo].[WebSite]'))
DROP INDEX [IX_WebSite] ON [dbo].[WebSite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [ix_recordtype] from [dbo].[tmp_PriceData]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'ix_recordtype' AND object_id = OBJECT_ID(N'[dbo].[tmp_PriceData]'))
DROP INDEX [ix_recordtype] ON [dbo].[tmp_PriceData]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [ix_custnum] from [dbo].[tmp_PriceData]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'ix_custnum' AND object_id = OBJECT_ID(N'[dbo].[tmp_PriceData]'))
DROP INDEX [ix_custnum] ON [dbo].[tmp_PriceData]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [ix_shiptonum] from [dbo].[tmp_PriceData]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'ix_shiptonum' AND object_id = OBJECT_ID(N'[dbo].[tmp_PriceData]'))
DROP INDEX [ix_shiptonum] ON [dbo].[tmp_PriceData]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [ix_partnum] from [dbo].[tmp_PriceData]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'ix_partnum' AND object_id = OBJECT_ID(N'[dbo].[tmp_PriceData]'))
DROP INDEX [ix_partnum] ON [dbo].[tmp_PriceData]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [ix_customerkeypart] from [dbo].[tmp_PriceData]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'ix_customerkeypart' AND object_id = OBJECT_ID(N'[dbo].[tmp_PriceData]'))
DROP INDEX [ix_customerkeypart] ON [dbo].[tmp_PriceData]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [ix_productkeypart] from [dbo].[tmp_PriceData]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'ix_productkeypart' AND object_id = OBJECT_ID(N'[dbo].[tmp_PriceData]'))
DROP INDEX [ix_productkeypart] ON [dbo].[tmp_PriceData]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping index [PK_WarehouseAlternate] from [dbo].[WarehouseAlternate]'
GO
IF EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_WarehouseAlternate' AND object_id = OBJECT_ID(N'[dbo].[WarehouseAlternate]'))
DROP INDEX [PK_WarehouseAlternate] ON [dbo].[WarehouseAlternate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[Customer_After_InsertUpdate] from [dbo].[Customer]'
GO
IF OBJECT_ID(N'[dbo].[Customer_After_InsertUpdate]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[Customer_After_InsertUpdate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[NewsArticle_After_Delete] from [dbo].[NewsArticle]'
GO
IF OBJECT_ID(N'[dbo].[NewsArticle_After_Delete]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[NewsArticle_After_Delete]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[OrderHistory_After_InsertUpdate] from [dbo].[OrderHistory]'
GO
IF OBJECT_ID(N'[dbo].[OrderHistory_After_InsertUpdate]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[OrderHistory_After_InsertUpdate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[Review_After_Delete] from [dbo].[Review]'
GO
IF OBJECT_ID(N'[dbo].[Review_After_Delete]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[Review_After_Delete]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[ApplicationLog_InsteadOf_Insert] from [dbo].[ApplicationLog]'
GO
IF OBJECT_ID(N'[dbo].[ApplicationLog_InsteadOf_Insert]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[ApplicationLog_InsteadOf_Insert]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[Category_After_Delete] from [dbo].[Category]'
GO
IF OBJECT_ID(N'[dbo].[Category_After_Delete]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[Category_After_Delete]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[Content_After_Update] from [dbo].[Content]'
GO
IF OBJECT_ID(N'[dbo].[Content_After_Update]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[Content_After_Update]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[CustomerProduct_After_Update] from [dbo].[CustomerProduct]'
GO
IF OBJECT_ID(N'[dbo].[CustomerProduct_After_Update]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[CustomerProduct_After_Update]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[Customer_After_Insert] from [dbo].[Customer]'
GO
IF OBJECT_ID(N'[dbo].[Customer_After_Insert]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[Customer_After_Insert]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[Dealer_After_Delete] from [dbo].[Dealer]'
GO
IF OBJECT_ID(N'[dbo].[Dealer_After_Delete]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[Dealer_After_Delete]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[EmailTemplate_After_Delete] from [dbo].[EmailTemplate]'
GO
IF OBJECT_ID(N'[dbo].[EmailTemplate_After_Delete]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[EmailTemplate_After_Delete]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[Product_After_Delete] from [dbo].[Product]'
GO
IF OBJECT_ID(N'[dbo].[Product_After_Delete]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[Product_After_Delete]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[Product_After_Insert] from [dbo].[Product]'
GO
IF OBJECT_ID(N'[dbo].[Product_After_Insert]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[Product_After_Insert]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[Product_After_Update] from [dbo].[Product]'
GO
IF OBJECT_ID(N'[dbo].[Product_After_Update]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[Product_After_Update]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[Specification_After_Delete] from [dbo].[Specification]'
GO
IF OBJECT_ID(N'[dbo].[Specification_After_Delete]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[Specification_After_Delete]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[WebPageContent_After_Delete] from [dbo].[WebPageContent]'
GO
IF OBJECT_ID(N'[dbo].[WebPageContent_After_Delete]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[WebPageContent_After_Delete]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping trigger [dbo].[WebPage_After_Delete] from [dbo].[WebPage]'
GO
IF OBJECT_ID(N'[dbo].[WebPage_After_Delete]', 'TR') IS NOT NULL
DROP TRIGGER [dbo].[WebPage_After_Delete]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Setup_RestorePermissions]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Setup_RestorePermissions]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Setup_RestorePermissions]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Setup_RemoveAllRoleMembers]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Setup_RemoveAllRoleMembers]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Setup_RemoveAllRoleMembers]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[Server_GetCache]'
GO
IF OBJECT_ID(N'[dbo].[Server_GetCache]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[Server_GetCache]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[Server_DeleteCacheByRoutePattern]'
GO
IF OBJECT_ID(N'[dbo].[Server_DeleteCacheByRoutePattern]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[Server_DeleteCacheByRoutePattern]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[Server_DeleteCacheByResourceUri]'
GO
IF OBJECT_ID(N'[dbo].[Server_DeleteCacheByResourceUri]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[Server_DeleteCacheByResourceUri]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[Server_DeleteCacheById]'
GO
IF OBJECT_ID(N'[dbo].[Server_DeleteCacheById]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[Server_DeleteCacheById]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[Server_ClearCache]'
GO
IF OBJECT_ID(N'[dbo].[Server_ClearCache]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[Server_ClearCache]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[Server_AddUpdateCache]'
GO
IF OBJECT_ID(N'[dbo].[Server_AddUpdateCache]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[Server_AddUpdateCache]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[Roundup_Sx]'
GO
IF OBJECT_ID(N'[dbo].[Roundup_Sx]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[Roundup_Sx]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[UrlFriendlyString]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UrlFriendlyString]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
DROP FUNCTION [dbo].[UrlFriendlyString]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[ProductPrice]'
GO
IF OBJECT_ID(N'[dbo].[ProductPrice]', 'U') IS NOT NULL
DROP TABLE [dbo].[ProductPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[CustomerProductPrice]'
GO
IF OBJECT_ID(N'[dbo].[CustomerProductPrice]', 'U') IS NOT NULL
DROP TABLE [dbo].[CustomerProductPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[ProductCost]'
GO
IF OBJECT_ID(N'[dbo].[ProductCost]', 'U') IS NOT NULL
DROP TABLE [dbo].[ProductCost]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[CustomerDiscount]'
GO
IF OBJECT_ID(N'[dbo].[CustomerDiscount]', 'U') IS NOT NULL
DROP TABLE [dbo].[CustomerDiscount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[County]'
GO
IF OBJECT_ID(N'[dbo].[County]', 'U') IS NOT NULL
DROP TABLE [dbo].[County]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[InvoiceLine]'
GO
IF OBJECT_ID(N'[dbo].[InvoiceLine]', 'U') IS NOT NULL
DROP TABLE [dbo].[InvoiceLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[City]'
GO
IF OBJECT_ID(N'[dbo].[City]', 'U') IS NOT NULL
DROP TABLE [dbo].[City]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[Invoice]'
GO
IF OBJECT_ID(N'[dbo].[Invoice]', 'U') IS NOT NULL
DROP TABLE [dbo].[Invoice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[ShippingClassification]'
GO
IF OBJECT_ID(N'[dbo].[ShippingClassification]', 'U') IS NOT NULL
DROP TABLE [dbo].[ShippingClassification]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[PriceCalculator_Epicor]'
GO
IF OBJECT_ID(N'[dbo].[PriceCalculator_Epicor]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[PriceCalculator_Epicor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[vw_aspnet_WebPartState_User]'
GO
IF OBJECT_ID(N'[dbo].[vw_aspnet_WebPartState_User]', 'V') IS NOT NULL
DROP VIEW [dbo].[vw_aspnet_WebPartState_User]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[vw_aspnet_WebPartState_Shared]'
GO
IF OBJECT_ID(N'[dbo].[vw_aspnet_WebPartState_Shared]', 'V') IS NOT NULL
DROP VIEW [dbo].[vw_aspnet_WebPartState_Shared]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[PriceCalculator_Visual]'
GO
IF OBJECT_ID(N'[dbo].[PriceCalculator_Visual]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[PriceCalculator_Visual]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[vw_aspnet_WebPartState_Paths]'
GO
IF OBJECT_ID(N'[dbo].[vw_aspnet_WebPartState_Paths]', 'V') IS NOT NULL
DROP VIEW [dbo].[vw_aspnet_WebPartState_Paths]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[PriceCalculator_Syteline]'
GO
IF OBJECT_ID(N'[dbo].[PriceCalculator_Syteline]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[PriceCalculator_Syteline]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[vw_aspnet_UsersInRoles]'
GO
IF OBJECT_ID(N'[dbo].[vw_aspnet_UsersInRoles]', 'V') IS NOT NULL
DROP VIEW [dbo].[vw_aspnet_UsersInRoles]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[vw_aspnet_Users]'
GO
IF OBJECT_ID(N'[dbo].[vw_aspnet_Users]', 'V') IS NOT NULL
DROP VIEW [dbo].[vw_aspnet_Users]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[PriceCalculator_Epicor9Vantage]'
GO
IF OBJECT_ID(N'[dbo].[PriceCalculator_Epicor9Vantage]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[PriceCalculator_Epicor9Vantage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[vw_aspnet_Roles]'
GO
IF OBJECT_ID(N'[dbo].[vw_aspnet_Roles]', 'V') IS NOT NULL
DROP VIEW [dbo].[vw_aspnet_Roles]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[vw_aspnet_Profiles]'
GO
IF OBJECT_ID(N'[dbo].[vw_aspnet_Profiles]', 'V') IS NOT NULL
DROP VIEW [dbo].[vw_aspnet_Profiles]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[vw_aspnet_MembershipUsers]'
GO
IF OBJECT_ID(N'[dbo].[vw_aspnet_MembershipUsers]', 'V') IS NOT NULL
DROP VIEW [dbo].[vw_aspnet_MembershipUsers]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[vw_aspnet_Applications]'
GO
IF OBJECT_ID(N'[dbo].[vw_aspnet_Applications]', 'V') IS NOT NULL
DROP VIEW [dbo].[vw_aspnet_Applications]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[GetVendorSalePrice_Epicor]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetVendorSalePrice_Epicor]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
DROP FUNCTION [dbo].[GetVendorSalePrice_Epicor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[GetPricingBaisis_Epicor]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetPricingBaisis_Epicor]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
DROP FUNCTION [dbo].[GetPricingBaisis_Epicor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[UpdatePricing_Batch]'
GO
IF OBJECT_ID(N'[dbo].[UpdatePricing_Batch]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[UpdatePricing_Batch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[UpdateItemCustPrice_Batch]'
GO
IF OBJECT_ID(N'[dbo].[UpdateItemCustPrice_Batch]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[UpdateItemCustPrice_Batch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[ItemCustPrice_Batch]'
GO
IF OBJECT_ID(N'[dbo].[ItemCustPrice_Batch]', 'U') IS NOT NULL
DROP TABLE [dbo].[ItemCustPrice_Batch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[UpdatePriceFormula_Batch]'
GO
IF OBJECT_ID(N'[dbo].[UpdatePriceFormula_Batch]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[UpdatePriceFormula_Batch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[PriceFormula_Batch]'
GO
IF OBJECT_ID(N'[dbo].[PriceFormula_Batch]', 'U') IS NOT NULL
DROP TABLE [dbo].[PriceFormula_Batch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[GetPriceMatrixId_Epicor]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetPriceMatrixId_Epicor]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
DROP FUNCTION [dbo].[GetPriceMatrixId_Epicor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[NightlyMaintenance]'
GO
IF OBJECT_ID(N'[dbo].[NightlyMaintenance]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[NightlyMaintenance]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[ScheduledTask]'
GO
IF OBJECT_ID(N'[dbo].[ScheduledTask]', 'U') IS NOT NULL
DROP TABLE [dbo].[ScheduledTask]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[GetListPrice_Epicor]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetListPrice_Epicor]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
DROP FUNCTION [dbo].[GetListPrice_Epicor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[PriceCalculator_Epicor9]'
GO
IF OBJECT_ID(N'[dbo].[PriceCalculator_Epicor9]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[PriceCalculator_Epicor9]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[UpdateItemPrice_Batch]'
GO
IF OBJECT_ID(N'[dbo].[UpdateItemPrice_Batch]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[UpdateItemPrice_Batch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[ItemPrice_Batch]'
GO
IF OBJECT_ID(N'[dbo].[ItemPrice_Batch]', 'U') IS NOT NULL
DROP TABLE [dbo].[ItemPrice_Batch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[GetPriceMatrix]'
GO
IF OBJECT_ID(N'[dbo].[GetPriceMatrix]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[GetPriceMatrix]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_WebEvent_LogEvent]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_WebEvent_LogEvent]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_WebEvent_LogEvent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_UsersInRoles_RemoveUsersFromRoles]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_UsersInRoles_RemoveUsersFromRoles]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_UsersInRoles_RemoveUsersFromRoles]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_UsersInRoles_IsUserInRole]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_UsersInRoles_IsUserInRole]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_UsersInRoles_IsUserInRole]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_UsersInRoles_GetUsersInRoles]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_UsersInRoles_GetUsersInRoles]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_UsersInRoles_GetUsersInRoles]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[GetPricingBasis_SyteLine]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetPricingBasis_SyteLine]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
DROP FUNCTION [dbo].[GetPricingBasis_SyteLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_UsersInRoles_GetRolesForUser]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_UsersInRoles_GetRolesForUser]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_UsersInRoles_GetRolesForUser]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[GetPriceMatrixId_Syteline]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetPriceMatrixId_Syteline]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
DROP FUNCTION [dbo].[GetPriceMatrixId_Syteline]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_UsersInRoles_FindUsersInRole]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_UsersInRoles_FindUsersInRole]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_UsersInRoles_FindUsersInRole]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[GetListPrice_Syteline]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetListPrice_Syteline]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
DROP FUNCTION [dbo].[GetListPrice_Syteline]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_UsersInRoles_AddUsersToRoles]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_UsersInRoles_AddUsersToRoles]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_UsersInRoles_AddUsersToRoles]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[GetVendorSalePrice_SyteLine]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetVendorSalePrice_SyteLine]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
DROP FUNCTION [dbo].[GetVendorSalePrice_SyteLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[RefreshProducts]'
GO
IF OBJECT_ID(N'[dbo].[RefreshProducts]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[RefreshProducts]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_UnRegisterSchemaVersion]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_UnRegisterSchemaVersion]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_UnRegisterSchemaVersion]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[RollupInventory]'
GO
IF OBJECT_ID(N'[dbo].[RollupInventory]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[RollupInventory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[RefreshInventory]'
GO
IF OBJECT_ID(N'[dbo].[RefreshInventory]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[RefreshInventory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[Review]'
GO
IF OBJECT_ID(N'[dbo].[Review]', 'U') IS NOT NULL
DROP TABLE [dbo].[Review]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Roles_RoleExists]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Roles_RoleExists]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Roles_RoleExists]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Roles_GetAllRoles]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Roles_GetAllRoles]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Roles_GetAllRoles]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[UpdatePriceMatrix_Batch]'
GO
IF OBJECT_ID(N'[dbo].[UpdatePriceMatrix_Batch]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[UpdatePriceMatrix_Batch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Roles_DeleteRole]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Roles_DeleteRole]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Roles_DeleteRole]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Roles_CreateRole]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Roles_CreateRole]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Roles_CreateRole]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_RegisterSchemaVersion]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_RegisterSchemaVersion]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_RegisterSchemaVersion]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Profile_SetProperties]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Profile_SetProperties]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Profile_SetProperties]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Profile_GetProperties]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Profile_GetProperties]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Profile_GetProperties]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Profile_GetProfiles]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Profile_GetProfiles]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Profile_GetProfiles]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Profile_GetNumberOfInactiveProfiles]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Profile_GetNumberOfInactiveProfiles]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Profile_GetNumberOfInactiveProfiles]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[RefreshPricing_Visual]'
GO
IF OBJECT_ID(N'[dbo].[RefreshPricing_Visual]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[RefreshPricing_Visual]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[PriceCalculator_Generic]'
GO
IF OBJECT_ID(N'[dbo].[PriceCalculator_Generic]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[PriceCalculator_Generic]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Profile_DeleteProfiles]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Profile_DeleteProfiles]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Profile_DeleteProfiles]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Users_DeleteUser]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Users_DeleteUser]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Users_DeleteUser]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[RefreshPricing_Epicor9Vantage]'
GO
IF OBJECT_ID(N'[dbo].[RefreshPricing_Epicor9Vantage]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[RefreshPricing_Epicor9Vantage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[tmp_PriceData]'
GO
IF OBJECT_ID(N'[dbo].[tmp_PriceData]', 'U') IS NOT NULL
DROP TABLE [dbo].[tmp_PriceData]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[PriceMatrix_Batch]'
GO
IF OBJECT_ID(N'[dbo].[PriceMatrix_Batch]', 'U') IS NOT NULL
DROP TABLE [dbo].[PriceMatrix_Batch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[ReportOrderHistoryLineView]'
GO
IF OBJECT_ID(N'[dbo].[ReportOrderHistoryLineView]', 'V') IS NOT NULL
DROP VIEW [dbo].[ReportOrderHistoryLineView]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Profile_DeleteInactiveProfiles]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Profile_DeleteInactiveProfiles]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Profile_DeleteInactiveProfiles]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[ReportOrderHistoryView]'
GO
IF OBJECT_ID(N'[dbo].[ReportOrderHistoryView]', 'V') IS NOT NULL
DROP VIEW [dbo].[ReportOrderHistoryView]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_PersonalizationPerUser_SetPageSettings]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser_SetPageSettings]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_PersonalizationPerUser_SetPageSettings]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_PersonalizationPerUser_ResetPageSettings]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser_ResetPageSettings]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_PersonalizationPerUser_ResetPageSettings]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_PersonalizationPerUser_GetPageSettings]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser_GetPageSettings]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_PersonalizationPerUser_GetPageSettings]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_PersonalizationAllUsers_SetPageSettings]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationAllUsers_SetPageSettings]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_PersonalizationAllUsers_SetPageSettings]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_PersonalizationAllUsers_ResetPageSettings]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationAllUsers_ResetPageSettings]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_PersonalizationAllUsers_ResetPageSettings]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_PersonalizationAllUsers_GetPageSettings]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationAllUsers_GetPageSettings]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_PersonalizationAllUsers_GetPageSettings]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_PersonalizationAdministration_ResetUserState]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationAdministration_ResetUserState]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_PersonalizationAdministration_ResetUserState]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[PriceCalculator_Sx]'
GO
IF OBJECT_ID(N'[dbo].[PriceCalculator_Sx]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[PriceCalculator_Sx]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_PersonalizationAdministration_ResetSharedState]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationAdministration_ResetSharedState]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_PersonalizationAdministration_ResetSharedState]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_PersonalizationAdministration_GetCountOfState]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationAdministration_GetCountOfState]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_PersonalizationAdministration_GetCountOfState]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[CalcMatrixResults_Sx]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CalcMatrixResults_Sx]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
DROP FUNCTION [dbo].[CalcMatrixResults_Sx]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[CalcSinglePrice_Sx]'
GO
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CalcSinglePrice_Sx]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
DROP FUNCTION [dbo].[CalcSinglePrice_Sx]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_PersonalizationAdministration_FindState]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationAdministration_FindState]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_PersonalizationAdministration_FindState]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_PersonalizationAdministration_DeleteAllState]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_PersonalizationAdministration_DeleteAllState]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_PersonalizationAdministration_DeleteAllState]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Personalization_GetApplicationId]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Personalization_GetApplicationId]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Personalization_GetApplicationId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Paths_CreatePath]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Paths_CreatePath]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Paths_CreatePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_UpdateUserInfo]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_UpdateUserInfo]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_UpdateUserInfo]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_UpdateUser]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_UpdateUser]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_UpdateUser]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_UnlockUser]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_UnlockUser]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_UnlockUser]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_SetPassword]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_SetPassword]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_SetPassword]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[RefreshAndRollupInventory]'
GO
IF OBJECT_ID(N'[dbo].[RefreshAndRollupInventory]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[RefreshAndRollupInventory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[InventoryTransaction]'
GO
IF OBJECT_ID(N'[dbo].[InventoryTransaction]', 'U') IS NOT NULL
DROP TABLE [dbo].[InventoryTransaction]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_ResetPassword]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_ResetPassword]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_ResetPassword]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_GetUserByUserId]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_GetUserByUserId]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_GetUserByUserId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_GetUserByName]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_GetUserByName]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_GetUserByName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_GetUserByEmail]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_GetUserByEmail]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_GetUserByEmail]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_GetPasswordWithFormat]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_GetPasswordWithFormat]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_GetPasswordWithFormat]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_GetPassword]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_GetPassword]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_GetPassword]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_GetNumberOfUsersOnline]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_GetNumberOfUsersOnline]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_GetNumberOfUsersOnline]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_GetAllUsers]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_GetAllUsers]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_GetAllUsers]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_FindUsersByName]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_FindUsersByName]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_FindUsersByName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_FindUsersByEmail]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_FindUsersByEmail]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_FindUsersByEmail]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_CreateUser]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_CreateUser]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_CreateUser]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Users_CreateUser]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Users_CreateUser]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Users_CreateUser]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Membership_ChangePasswordQuestionAndAnswer]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Membership_ChangePasswordQuestionAndAnswer]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Membership_ChangePasswordQuestionAndAnswer]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_CheckSchemaVersion]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_CheckSchemaVersion]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_CheckSchemaVersion]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_Applications_CreateApplication]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_Applications_CreateApplication]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_Applications_CreateApplication]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Dropping [dbo].[aspnet_AnyDataInTables]'
GO
IF OBJECT_ID(N'[dbo].[aspnet_AnyDataInTables]', 'P') IS NOT NULL
DROP PROCEDURE [dbo].[aspnet_AnyDataInTables]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Product]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Product]', N'UrlSegment') IS NULL
ALTER TABLE [dbo].[Product] ADD[UrlSegment] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_Product_UrlSegment] DEFAULT ('')
IF COL_LENGTH(N'[dbo].[Product]', N'LowStockLevel') IS NULL
ALTER TABLE [dbo].[Product] ADD[LowStockLevel] [decimal] (18, 5) NOT NULL CONSTRAINT [DF_Product_SafetyStock] DEFAULT ((0))
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Product]', N'Description') IS NOT NULL
ALTER TABLE [dbo].[Product] DROP COLUMN [Description]
IF COL_LENGTH(N'[dbo].[Product]', N'QtyPerPackageLength') IS NOT NULL
ALTER TABLE [dbo].[Product] DROP COLUMN [QtyPerPackageLength]
IF COL_LENGTH(N'[dbo].[Product]', N'QtyPerPackageWidth') IS NOT NULL
ALTER TABLE [dbo].[Product] DROP COLUMN [QtyPerPackageWidth]
IF COL_LENGTH(N'[dbo].[Product]', N'QtyPerPackageHeight') IS NOT NULL
ALTER TABLE [dbo].[Product] DROP COLUMN [QtyPerPackageHeight]
IF COL_LENGTH(N'[dbo].[Product]', N'EachDescription') IS NOT NULL
ALTER TABLE [dbo].[Product] DROP COLUMN [EachDescription]
IF COL_LENGTH(N'[dbo].[Product]', N'StyleSheet') IS NOT NULL
ALTER TABLE [dbo].[Product] DROP COLUMN [StyleSheet]
IF COL_LENGTH(N'[dbo].[Product]', N'UserVendorMarkup') IS NOT NULL
ALTER TABLE [dbo].[Product] DROP COLUMN [UserVendorMarkup]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Product]', N'ProductId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Product]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Product].[ProductId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Product]', N'Active') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Product]', N'ActivateOn') IS NULL)
EXEC sp_rename N'[dbo].[Product].[Active]', N'ActivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Product]', N'Deactivate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Product]', N'DeactivateOn') IS NULL)
EXEC sp_rename N'[dbo].[Product].[Deactivate]', N'DeactivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Product]', N'OutOfStock') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Product]', N'IsOutOfStock') IS NULL)
EXEC sp_rename N'[dbo].[Product].[OutOfStock]', N'IsOutOfStock', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Product]', N'SubscriptionIncludeInInitialOrder') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Product]', N'SubscriptionAddToInitialOrder') IS NULL)
EXEC sp_rename N'[dbo].[Product].[SubscriptionIncludeInInitialOrder]', N'SubscriptionAddToInitialOrder', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Product]', N'BasicSaleStart') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Product]', N'BasicSaleStartDate') IS NULL)
EXEC sp_rename N'[dbo].[Product].[BasicSaleStart]', N'BasicSaleStartDate', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Product]', N'BasicSaleEnd') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Product]', N'BasicSaleEndDate') IS NULL)
EXEC sp_rename N'[dbo].[Product].[BasicSaleEnd]', N'BasicSaleEndDate', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Product]', N'Cost') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Product]', N'UnitCost') IS NULL)
EXEC sp_rename N'[dbo].[Product].[Cost]', N'UnitCost', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Product]', N'AltText') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Product]', N'ImageAltText') IS NULL)
EXEC sp_rename N'[dbo].[Product].[AltText]', N'ImageAltText', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [ERPDescription] [nvarchar] (2048) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SmallImagePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [MediumImagePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [LargeImagePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [ActivateOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [PageTitle] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [DisplayPricePerPiece] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [IsGiftCard] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [AllowAnyGiftCardAmount] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [IsOutOfStock] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [ERPManaged] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [IsSubscription] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionFixedPrice] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionAddToInitialOrder] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionAllMonths] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionJanuary] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionFebruary] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionMarch] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionApril] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionMay] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionJune] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionJuly] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionAugust] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionSeptember] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionOctober] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionNovember] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [SubscriptionDecember] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [UseVendorMarkup] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [TrackInventory] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [IsConfigured] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [BasicSaleStartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [BasicSaleEndDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [HasMsds] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [IsHazardousGood] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [IsDiscontinued] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [IsSpecialOrder] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [IsFixedConfiguration] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Product] ALTER COLUMN [ImageAltText] [nvarchar] (2048) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Product] on [dbo].[Product]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Product' AND object_id = OBJECT_ID(N'[dbo].[Product]'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [PK_Product] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Product_NaturalKey] on [dbo].[Product]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Product_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Product]'))
CREATE NONCLUSTERED INDEX [IX_Product_NaturalKey] ON [dbo].[Product] ([ERPNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Product_Name] on [dbo].[Product]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Product_Name' AND object_id = OBJECT_ID(N'[dbo].[Product]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Product_Name] ON [dbo].[Product] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Customer]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Customer]', N'IsBillTo') IS NULL
ALTER TABLE [dbo].[Customer] ADD[IsBillTo] [bit] NOT NULL CONSTRAINT [DF_Customer_IsBillTo] DEFAULT ((1))
IF COL_LENGTH(N'[dbo].[Customer]', N'IsShipTo') IS NULL
ALTER TABLE [dbo].[Customer] ADD[IsShipTo] [bit] NOT NULL CONSTRAINT [DF_Customer_IsShipTo] DEFAULT ((1))
IF COL_LENGTH(N'[dbo].[Customer]', N'IsSoldTo') IS NULL
ALTER TABLE [dbo].[Customer] ADD[IsSoldTo] [bit] NOT NULL CONSTRAINT [DF_Customer_IsSoldTo] DEFAULT ((1))
IF COL_LENGTH(N'[dbo].[Customer]', N'DefaultWarehouseId') IS NULL
ALTER TABLE [dbo].[Customer] ADD[DefaultWarehouseId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Customer]', N'Contact2') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [Contact2]
IF COL_LENGTH(N'[dbo].[Customer]', N'Contact3') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [Contact3]
IF COL_LENGTH(N'[dbo].[Customer]', N'Phone2') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [Phone2]
IF COL_LENGTH(N'[dbo].[Customer]', N'Phone3') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [Phone3]
IF COL_LENGTH(N'[dbo].[Customer]', N'Salesman') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [Salesman]
IF COL_LENGTH(N'[dbo].[Customer]', N'InvoiceFrequency') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [InvoiceFrequency]
IF COL_LENGTH(N'[dbo].[Customer]', N'County') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [County]
IF COL_LENGTH(N'[dbo].[Customer]', N'TermsOfUse') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [TermsOfUse]
IF COL_LENGTH(N'[dbo].[Customer]', N'CustomerReferenceLabel1') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [CustomerReferenceLabel1]
IF COL_LENGTH(N'[dbo].[Customer]', N'CustomerReferenceLabel2') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [CustomerReferenceLabel2]
IF COL_LENGTH(N'[dbo].[Customer]', N'SendFax') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [SendFax]
IF COL_LENGTH(N'[dbo].[Customer]', N'CompanyId') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [CompanyId]
IF COL_LENGTH(N'[dbo].[Customer]', N'Directory') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [Directory]
IF COL_LENGTH(N'[dbo].[Customer]', N'OpenInvoiceAmount') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [OpenInvoiceAmount]
IF COL_LENGTH(N'[dbo].[Customer]', N'OpenOrderAmount') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [OpenOrderAmount]
IF COL_LENGTH(N'[dbo].[Customer]', N'AgingBucket1') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [AgingBucket1]
IF COL_LENGTH(N'[dbo].[Customer]', N'AgingBucket2') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [AgingBucket2]
IF COL_LENGTH(N'[dbo].[Customer]', N'AgingBucket3') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [AgingBucket3]
IF COL_LENGTH(N'[dbo].[Customer]', N'AgingBucket4') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [AgingBucket4]
IF COL_LENGTH(N'[dbo].[Customer]', N'AgingBucket5') IS NOT NULL
ALTER TABLE [dbo].[Customer] DROP COLUMN [AgingBucket5]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Customer]', N'CustomerId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Customer]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Customer].[CustomerId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Customer]', N'Company') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Customer]', N'CompanyName') IS NULL)
EXEC sp_rename N'[dbo].[Customer].[Company]', N'CompanyName', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Customer]', N'Contact1') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Customer]', N'ContactFullName') IS NULL)
EXEC sp_rename N'[dbo].[Customer].[Contact1]', N'ContactFullName', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Customer]', N'Phone1') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Customer]', N'Phone') IS NULL)
EXEC sp_rename N'[dbo].[Customer].[Phone1]', N'Phone', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Customer]', N'Zip') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Customer]', N'PostalCode') IS NULL)
EXEC sp_rename N'[dbo].[Customer].[Zip]', N'PostalCode', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Customer]', N'Discount') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Customer]', N'DiscountPercent') IS NULL)
EXEC sp_rename N'[dbo].[Customer].[Discount]', N'DiscountPercent', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Customer]', N'Image') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Customer]', N'LogoImagePath') IS NULL)
EXEC sp_rename N'[dbo].[Customer].[Image]', N'LogoImagePath', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Customer]', N'ModifyDate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Customer]', N'ModifedOn') IS NULL)
EXEC sp_rename N'[dbo].[Customer].[ModifyDate]', N'ModifedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Customer]', N'PrimarySalesmanId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Customer]', N'PrimarySalespersonId') IS NULL)
EXEC sp_rename N'[dbo].[Customer].[PrimarySalesmanId]', N'PrimarySalespersonId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [ShipEarly] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [ShipPartial] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [CreditHold] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [CreditLimit] [decimal] (18, 5) NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [SendEmail] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [LogoImagePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [AllowDropShip] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [DropShipFeeRequired] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [IsDropShip] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [IsGuest] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [CustomLandingPage] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [IgnoreProductRestrictions] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Customer] ALTER COLUMN [ModifedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Customer] on [dbo].[Customer]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Customer' AND object_id = OBJECT_ID(N'[dbo].[Customer]'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Customer_CustomerNumber] on [dbo].[Customer]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Customer_CustomerNumber' AND object_id = OBJECT_ID(N'[dbo].[Customer]'))
CREATE NONCLUSTERED INDEX [IX_Customer_CustomerNumber] ON [dbo].[Customer] ([CustomerNumber], [IsShipTo])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Customer_NaturalKey] on [dbo].[Customer]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Customer_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Customer]'))
CREATE NONCLUSTERED INDEX [IX_Customer_NaturalKey] ON [dbo].[Customer] ([ERPNumber], [ERPSequence])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Customer_Salesperson] on [dbo].[Customer]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Customer_Salesperson' AND object_id = OBJECT_ID(N'[dbo].[Customer]'))
CREATE NONCLUSTERED INDEX [IX_Customer_Salesperson] ON [dbo].[Customer] ([PrimarySalespersonId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[DocumentManager]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[DocumentManager]', N'DocumentManagerId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[DocumentManager]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[DocumentManager].[DocumentManagerId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_DocumentManager] on [dbo].[DocumentManager]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_DocumentManager' AND object_id = OBJECT_ID(N'[dbo].[DocumentManager]'))
ALTER TABLE [dbo].[DocumentManager] ADD CONSTRAINT [PK_DocumentManager] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ContentManager]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ContentManager]', N'ContentManagerId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ContentManager]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ContentManager].[ContentManagerId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ContentManager] on [dbo].[ContentManager]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ContentManager' AND object_id = OBJECT_ID(N'[dbo].[ContentManager]'))
ALTER TABLE [dbo].[ContentManager] ADD CONSTRAINT [PK_ContentManager] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[Product_After_Delete] on [dbo].[Product]'
GO
IF OBJECT_ID(N'[dbo].[Product_After_Delete]', 'TR') IS NULL
EXEC sp_executesql N'CREATE TRIGGER [dbo].[Product_After_Delete]
   ON  [dbo].[Product]
   AFTER DELETE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
    DELETE cm FROM ContentManager cm INNER JOIN DELETED d ON d.ContentManagerId = cm.Id
    DELETE dm FROM DocumentManager dm INNER JOIN DELETED d ON d.DocumentManagerId = dm.Id

    -- When an deleting a StyleParent, null out StyleParentId on StyleChildren
	UPDATE p SET StyleParentId = NULL FROM Product p, DELETED d WHERE p.StyleParentId = d.Id
	
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[UrlFriendlyString]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UrlFriendlyString]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
EXEC sp_executesql N'-- =============================================
-- Author:		Darwin Zins
-- Create date: 02/13/2015
-- Description:	To convert a string to URLFriendly
-- =============================================
CREATE FUNCTION [dbo].[UrlFriendlyString] 
(
	@UrlValue nvarchar(255)
)
RETURNS nvarchar(255)
AS
BEGIN
       SELECT @UrlValue = 
                     REPLACE(
                     REPLACE(
                     REPLACE(
                     REPLACE(
                     REPLACE(
                     REPLACE(
                     REPLACE(
                     REPLACE(
                     REPLACE(
                     REPLACE(
                     REPLACE(
					 REPLACE(
                     LTRIM(RTRIM(@UrlValue))
                     , '' '', ''-'')
                     , '','', ''-'')
					 ,''#'',''-'')
                     , '''''''', '''')
					 , ''"'','''')
                     , ''('', '''')
                     , '')'', '''')
                     , ''&'', ''And'')
                     , ''+'', '''')
                     , ''\'', '''')
                     , ''---'', ''-'')
                     , ''--'', ''-'')
      
	RETURN @UrlValue
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[Product_After_Update] on [dbo].[Product]'
GO
IF OBJECT_ID(N'[dbo].[Product_After_Update]', 'TR') IS NULL
EXEC sp_executesql N'
-- =============================================
-- Author:		Darwin Zins
-- Create date: 08/18/2010
-- Description:	Product Update Trigger
-- Update 02/13/15 to handle UrlSegment to strip out unwanted characters
-- =============================================
CREATE TRIGGER [dbo].[Product_After_Update]
   ON  [dbo].[Product]
   AFTER UPDATE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- When an update is made where the StyleClass is removed from the Product, null out StyleParentId on StyleChildren
	UPDATE p SET StyleParentId = NULL FROM Product p INNER JOIN INSERTED i ON i.Id = p.StyleParentId 
		INNER JOIN DELETED d ON d.Id = p.StyleParentId WHERE (NOT d.StyleClassId IS NULL) AND i.StyleClassId IS NULL

	-- Set Product.IndexStatus to 1 when products and children are updated, but not if IndexStatus is manually being set to 0
	UPDATE p SET p.IndexStatus = 1 FROM Product p JOIN DELETED d ON 
		p.Id = d.Id OR p.Id = d.StyleParentId
		WHERE d.IndexStatus = 0	

	-- Update UrlSegment
	UPDATE p SET p.UrlSegment = dbo.UrlFriendlyString(p.UrlSegment) FROM
	  Product p JOIN Inserted i ON p.Id = i.Id
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[Product_After_Insert] on [dbo].[Product]'
GO
IF OBJECT_ID(N'[dbo].[Product_After_Insert]', 'TR') IS NULL
EXEC sp_executesql N'-- =============================================
-- Author:		Peter Gaard
-- Create date: 08/25/2014
-- Description:	Product Insert Trigger
-- Modified 2/13/15 to handle UrlSegment to strip out unwanted characters
-- =============================================
CREATE TRIGGER [dbo].[Product_After_Insert]
   ON  [dbo].[Product]
   AFTER INSERT
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	-- Update UrlSegment
	UPDATE p SET p.UrlSegment = dbo.UrlFriendlyString(p.UrlSegment) FROM
	  Product p JOIN Inserted i ON p.Id = i.Id

	-- Set Product.IndexStatus to 1 when products and children are created
	UPDATE p SET p.IndexStatus = 1 FROM Product p JOIN INSERTED i ON 
		p.Id = i.Id OR p.Id = i.StyleParentId
		WHERE i.IndexStatus = 0	
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[Customer_After_Insert] on [dbo].[Customer]'
GO
IF OBJECT_ID(N'[dbo].[Customer_After_Insert]', 'TR') IS NULL
EXEC sp_executesql N'CREATE TRIGGER [dbo].[Customer_After_Insert] 
   ON  [dbo].[Customer]
   AFTER INSERT
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
    UPDATE c SET c.ParentId = p.Id, IsBillTo = 0 FROM Customer c 
		INNER JOIN INSERTED i ON i.Id = c.Id
		INNER JOIN Customer p ON p.CustomerNumber = c.CustomerNumber AND 
			p.Id <> c.Id AND 
			(p.ParentId IS NULL OR p.ParentId = p.Id)

END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[CacheState]'
GO
IF OBJECT_ID(N'[dbo].[CacheState]', 'U') IS NULL
CREATE TABLE [dbo].[CacheState]
(
[CacheKeyHash] [binary] (20) NOT NULL,
[RoutePattern] [nvarchar] (256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ResourceUri] [nvarchar] (256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ETag] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[LastModified] [datetime] NOT NULL
)
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CacheState] on [dbo].[CacheState]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CacheState' AND object_id = OBJECT_ID(N'[dbo].[CacheState]'))
ALTER TABLE [dbo].[CacheState] ADD CONSTRAINT [PK_CacheState] PRIMARY KEY CLUSTERED  ([CacheKeyHash])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CacheState_RoutePattern] on [dbo].[CacheState]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CacheState_RoutePattern' AND object_id = OBJECT_ID(N'[dbo].[CacheState]'))
CREATE NONCLUSTERED INDEX [IX_CacheState_RoutePattern] ON [dbo].[CacheState] ([RoutePattern])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CacheState_ResourceUri] on [dbo].[CacheState]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CacheState_ResourceUri' AND object_id = OBJECT_ID(N'[dbo].[CacheState]'))
CREATE NONCLUSTERED INDEX [IX_CacheState_ResourceUri] ON [dbo].[CacheState] ([ResourceUri])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[Server_AddUpdateCache]'
GO
IF OBJECT_ID(N'[dbo].[Server_AddUpdateCache]', 'P') IS NULL
EXEC sp_executesql N'
-- =============================================
-- Author:		Ali Kheyrollahi
-- Create date: 2012-07-12
-- Description:	Adds or updates cache entry
-- =============================================
CREATE PROCEDURE [dbo].[Server_AddUpdateCache]
	@cacheKeyHash	BINARY(20),
	@routePattern	NVARCHAR(256),
	@resourceUri	NVARCHAR(256),
	@eTag			NVARCHAR(100),
	@lastModified	DATETIME
	 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON

	BEGIN TRAN
	IF EXISTS (SELECT 1 FROM dbo.CacheState 
			WITH (UPDLOCK,SERIALIZABLE) WHERE CacheKeyHash = @cacheKeyHash)
		BEGIN
			UPDATE dbo.CacheState SET 
					ETag = @eTag,
					LastModified = @lastModified,
					RoutePattern = @routePattern,
					ResourceUri	 = @resourceUri
				WHERE CacheKeyHash = @cacheKeyHash
		END
	ELSE
	
		BEGIN
			INSERT INTO dbo.CacheState 
				(CacheKeyHash, RoutePattern, ResourceUri, ETag, LastModified)
			values 
				(@cacheKeyHash, @routePattern, @resourceUri, @eTag, @lastModified)
		END
	COMMIT TRAN

END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[Server_ClearCache]'
GO
IF OBJECT_ID(N'[dbo].[Server_ClearCache]', 'P') IS NULL
EXEC sp_executesql N'
-- =============================================
-- Author:		Carl Duguay
-- Create date:	2013-07-10
-- Description:	Removes all CacheKey records
-- =============================================
CREATE PROCEDURE [dbo].[Server_ClearCache]	 
AS
BEGIN
	SET NOCOUNT OFF
	DELETE FROM [dbo].[CacheState]
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[Server_DeleteCacheById]'
GO
IF OBJECT_ID(N'[dbo].[Server_DeleteCacheById]', 'P') IS NULL
EXEC sp_executesql N'
-- =============================================
-- Author:		Ali Kheyrollahi
-- Create date: 2012-07-12
-- Description:	Deletes a CacheKey record by its id
-- =============================================
CREATE PROCEDURE [dbo].[Server_DeleteCacheById]
	@CacheKeyHash BINARY(20) 
AS
BEGIN
	SET NOCOUNT OFF
	DELETE FROM dbo.CacheState WHERE CacheKeyHash = @CacheKeyHash
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[Server_DeleteCacheByResourceUri]'
GO
IF OBJECT_ID(N'[dbo].[Server_DeleteCacheByResourceUri]', 'P') IS NULL
EXEC sp_executesql N'
-- =============================================
-- Author:		Ali Kheyrollahi
-- Create date: 2013-11-16
-- Description:	Deletes all CacheKey records by its resource uri
-- =============================================
CREATE PROCEDURE [dbo].[Server_DeleteCacheByResourceUri]
	@resourceUri NVARCHAR(256) 
AS
BEGIN
	SET NOCOUNT OFF

	DELETE FROM dbo.CacheState WHERE ResourceUri = @resourceUri
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[Server_DeleteCacheByRoutePattern]'
GO
IF OBJECT_ID(N'[dbo].[Server_DeleteCacheByRoutePattern]', 'P') IS NULL
EXEC sp_executesql N'
-- =============================================
-- Author:		Ali Kheyrollahi
-- Create date: 2012-07-12
-- Description:	Deletes all CacheKey records by its route pattern
-- =============================================
CREATE PROCEDURE [dbo].[Server_DeleteCacheByRoutePattern]
	@routePattern NVARCHAR(256) 
AS
BEGIN
	SET NOCOUNT OFF

	DELETE FROM dbo.CacheState WHERE RoutePattern = @routePattern
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Specification]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Specification]', N'SpecificationId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Specification]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Specification].[SpecificationId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Specification]', N'Active') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Specification]', N'IsActive') IS NULL)
EXEC sp_rename N'[dbo].[Specification].[Active]', N'IsActive', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Specification] ALTER COLUMN [Description] [nvarchar] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Specification] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Specification] on [dbo].[Specification]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Specification' AND object_id = OBJECT_ID(N'[dbo].[Specification]'))
ALTER TABLE [dbo].[Specification] ADD CONSTRAINT [PK_Specification] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Specification_ContentManagerId] on [dbo].[Specification]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Specification_ContentManagerId' AND object_id = OBJECT_ID(N'[dbo].[Specification]'))
CREATE NONCLUSTERED INDEX [IX_Specification_ContentManagerId] ON [dbo].[Specification] ([ContentManagerId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Specification_NaturalKey] on [dbo].[Specification]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Specification_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Specification]'))
CREATE NONCLUSTERED INDEX [IX_Specification_NaturalKey] ON [dbo].[Specification] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[Specification_After_Delete] on [dbo].[Specification]'
GO
IF OBJECT_ID(N'[dbo].[Specification_After_Delete]', 'TR') IS NULL
EXEC sp_executesql N'-- =============================================
-- Author:		Darwin Zins
-- Create date: 4/7/2014
-- Description:	Delete contained ContentManager
-- =============================================
CREATE TRIGGER [dbo].[Specification_After_Delete]
   ON  [dbo].[Specification]
   AFTER DELETE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
    DELETE cm FROM ContentManager cm INNER JOIN DELETED d ON d.ContentManagerId = cm.Id

END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Country]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Country]', N'CountryId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Country]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Country].[CountryId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Country] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Country] on [dbo].[Country]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Country' AND object_id = OBJECT_ID(N'[dbo].[Country]'))
ALTER TABLE [dbo].[Country] ADD CONSTRAINT [PK_Country] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Country_NaturalKey] on [dbo].[Country]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Country_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Country]'))
CREATE NONCLUSTERED INDEX [IX_Country_NaturalKey] ON [dbo].[Country] ([ISOCode2])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Country] on [dbo].[Country]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Country' AND object_id = OBJECT_ID(N'[dbo].[Country]'))
CREATE NONCLUSTERED INDEX [IX_Country] ON [dbo].[Country] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[Server_GetCache]'
GO
IF OBJECT_ID(N'[dbo].[Server_GetCache]', 'P') IS NULL
EXEC sp_executesql N'
-- =============================================
-- Author:		Ali Kheyrollahi
-- Create date: 2012-07-12
-- Description:	returns cache entry by its Id
-- =============================================
CREATE PROCEDURE [dbo].[Server_GetCache]
	@cacheKeyHash		BINARY(20)
	 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT 
		ETag, LastModified
	FROM
		dbo.CacheState
	WHERE
		CacheKeyHash = @cacheKeyHash

END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Dealer]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Dealer]', N'DealerId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Dealer]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Dealer].[DealerId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Dealer]', N'Zip') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Dealer]', N'PostalCode') IS NULL)
EXEC sp_rename N'[dbo].[Dealer].[Zip]', N'PostalCode', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Dealer]', N'Phone1') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Dealer]', N'Phone') IS NULL)
EXEC sp_rename N'[dbo].[Dealer].[Phone1]', N'Phone', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Dealer]', N'Fax1') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Dealer]', N'Fax') IS NULL)
EXEC sp_rename N'[dbo].[Dealer].[Fax1]', N'Fax', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Dealers] on [dbo].[Dealer]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Dealers' AND object_id = OBJECT_ID(N'[dbo].[Dealer]'))
ALTER TABLE [dbo].[Dealer] ADD CONSTRAINT [PK_Dealers] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Dealer] on [dbo].[Dealer]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Dealer' AND object_id = OBJECT_ID(N'[dbo].[Dealer]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Dealer] ON [dbo].[Dealer] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[EmailTemplate]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[EmailTemplate]', N'EmailTemplateID') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[EmailTemplate]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[EmailTemplate].[EmailTemplateID]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_EmailTemplate] on [dbo].[EmailTemplate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_EmailTemplate' AND object_id = OBJECT_ID(N'[dbo].[EmailTemplate]'))
ALTER TABLE [dbo].[EmailTemplate] ADD CONSTRAINT [PK_EmailTemplate] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Promotion]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Promotion]', N'PromotionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Promotion]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Promotion].[PromotionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Promotion]', N'Active') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Promotion]', N'ActivateOn') IS NULL)
EXEC sp_rename N'[dbo].[Promotion].[Active]', N'ActivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Promotion]', N'Deactivate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Promotion]', N'DeactivateOn') IS NULL)
EXEC sp_rename N'[dbo].[Promotion].[Deactivate]', N'DeactivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Promotion]', N'IsActive') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Promotion]', N'IsLive') IS NULL)
EXEC sp_rename N'[dbo].[Promotion].[IsActive]', N'IsLive', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Promotion] ALTER COLUMN [DisplayMessage] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Promotion] ALTER COLUMN [Description] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Promotion] ALTER COLUMN [DiscountAmount] [decimal] (18, 5) NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Promotion] ALTER COLUMN [ActivateOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Promotion] ALTER COLUMN [DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Promotion] ALTER COLUMN [IsPercentage] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Promotion] ALTER COLUMN [IsFreight] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Promotion] ALTER COLUMN [IsAutomatic] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Promotion] ALTER COLUMN [IsLive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Promotion] on [dbo].[Promotion]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Promotion' AND object_id = OBJECT_ID(N'[dbo].[Promotion]'))
ALTER TABLE [dbo].[Promotion] ADD CONSTRAINT [PK_Promotion] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Promotion_IsLive] on [dbo].[Promotion]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Promotion_IsLive' AND object_id = OBJECT_ID(N'[dbo].[Promotion]'))
CREATE NONCLUSTERED INDEX [IX_Promotion_IsLive] ON [dbo].[Promotion] ([IsLive])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Promotion_NaturalKey] on [dbo].[Promotion]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Promotion_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Promotion]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Promotion_NaturalKey] ON [dbo].[Promotion] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ShipVia]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShipVia]', N'ShipViaId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShipVia]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ShipVia].[ShipViaId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShipVia]', N'Active') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShipVia]', N'ActivateOn') IS NULL)
EXEC sp_rename N'[dbo].[ShipVia].[Active]', N'ActivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShipVia]', N'Deactivate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShipVia]', N'DeactivateOn') IS NULL)
EXEC sp_rename N'[dbo].[ShipVia].[Deactivate]', N'DeactivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ShipVia] ALTER COLUMN [ActivateOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ShipVia] ALTER COLUMN [DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ShipVia] ALTER COLUMN [Enable] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ShipVia] ALTER COLUMN [IsDefault] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ShipVia] ALTER COLUMN [AllowScheduledShipDate] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ShipVia] on [dbo].[ShipVia]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ShipVia' AND object_id = OBJECT_ID(N'[dbo].[ShipVia]'))
ALTER TABLE [dbo].[ShipVia] ADD CONSTRAINT [PK_ShipVia] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ShipVia_Carrier_NaturalKey] on [dbo].[ShipVia]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ShipVia_Carrier_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[ShipVia]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ShipVia_Carrier_NaturalKey] ON [dbo].[ShipVia] ([CarrierId], [ShipCode])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[WebPage]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[WebPage]', N'WebPageId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[WebPage]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[WebPage].[WebPageId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_WebPage] on [dbo].[WebPage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_WebPage' AND object_id = OBJECT_ID(N'[dbo].[WebPage]'))
ALTER TABLE [dbo].[WebPage] ADD CONSTRAINT [PK_WebPage] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ApplicationLog]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ApplicationLog]', N'ApplicationLogId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ApplicationLog]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ApplicationLog].[ApplicationLogId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ApplicationLog] ALTER COLUMN [LogDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ApplicationLog] on [dbo].[ApplicationLog]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ApplicationLog' AND object_id = OBJECT_ID(N'[dbo].[ApplicationLog]'))
ALTER TABLE [dbo].[ApplicationLog] ADD CONSTRAINT [PK_ApplicationLog] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ApplicationLog_LogDate] on [dbo].[ApplicationLog]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ApplicationLog_LogDate' AND object_id = OBJECT_ID(N'[dbo].[ApplicationLog]'))
CREATE NONCLUSTERED INDEX [IX_ApplicationLog_LogDate] ON [dbo].[ApplicationLog] ([LogDate])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[ApplicationLog_InsteadOf_Insert] on [dbo].[ApplicationLog]'
GO
IF OBJECT_ID(N'[dbo].[ApplicationLog_InsteadOf_Insert]', 'TR') IS NULL
EXEC sp_executesql N'CREATE TRIGGER [dbo].[ApplicationLog_InsteadOf_Insert]
	ON  [dbo].[ApplicationLog]
	INSTEAD OF INSERT
AS 
BEGIN
	SET NOCOUNT ON;

	INSERT INTO ApplicationLog (BatchNumber, Source, Message, Type, ErrorCount) SELECT BatchNumber, Source, left(Message, 100000), Type, ErrorCount FROM INSERTED
END


SET ANSI_NULLS ON
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[WebSite]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[WebSite]', N'TopContent') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [TopContent]
IF COL_LENGTH(N'[dbo].[WebSite]', N'ShowTopContent') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [ShowTopContent]
IF COL_LENGTH(N'[dbo].[WebSite]', N'LeftContent') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [LeftContent]
IF COL_LENGTH(N'[dbo].[WebSite]', N'ShowLeftContent') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [ShowLeftContent]
IF COL_LENGTH(N'[dbo].[WebSite]', N'RightContent') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [RightContent]
IF COL_LENGTH(N'[dbo].[WebSite]', N'ShowRightContent') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [ShowRightContent]
IF COL_LENGTH(N'[dbo].[WebSite]', N'BottomContent') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [BottomContent]
IF COL_LENGTH(N'[dbo].[WebSite]', N'ShowBottomContent') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [ShowBottomContent]
IF COL_LENGTH(N'[dbo].[WebSite]', N'OpeningPageTags') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [OpeningPageTags]
IF COL_LENGTH(N'[dbo].[WebSite]', N'ClosingPageTags') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [ClosingPageTags]
IF COL_LENGTH(N'[dbo].[WebSite]', N'Title') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [Title]
IF COL_LENGTH(N'[dbo].[WebSite]', N'HeaderContent') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [HeaderContent]
IF COL_LENGTH(N'[dbo].[WebSite]', N'BodyStyle') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [BodyStyle]
IF COL_LENGTH(N'[dbo].[WebSite]', N'StyleSheet') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [StyleSheet]
IF COL_LENGTH(N'[dbo].[WebSite]', N'JavaScript') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [JavaScript]
IF COL_LENGTH(N'[dbo].[WebSite]', N'ERPServiceUrl') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [ERPServiceUrl]
IF COL_LENGTH(N'[dbo].[WebSite]', N'ERPServiceTimeout') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [ERPServiceTimeout]
IF COL_LENGTH(N'[dbo].[WebSite]', N'TermsOfUse') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [TermsOfUse]
IF COL_LENGTH(N'[dbo].[WebSite]', N'HostCompanyName') IS NOT NULL
ALTER TABLE [dbo].[WebSite] DROP COLUMN [HostCompanyName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[WebSite]', N'WebSiteId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[WebSite]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[WebSite].[WebSiteId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebSite] ALTER COLUMN [Description] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebSite] ALTER COLUMN [DomainName] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebSite] ALTER COLUMN [MapProductsToCategories] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebSite] ALTER COLUMN [AllowMultiplePromotions] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebSite] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebSite] ALTER COLUMN [IsRestricted] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_WebSite] on [dbo].[WebSite]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_WebSite' AND object_id = OBJECT_ID(N'[dbo].[WebSite]'))
ALTER TABLE [dbo].[WebSite] ADD CONSTRAINT [PK_WebSite] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_WebSite_NaturalKey] on [dbo].[WebSite]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_WebSite_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[WebSite]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_WebSite_NaturalKey] ON [dbo].[WebSite] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Salesperson]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Salesperson]', N'SalesManagerId') IS NULL
ALTER TABLE [dbo].[Salesperson] ADD[SalesManagerId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Salesperson]', N'SalesmanId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Salesperson]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Salesperson].[SalesmanId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Salesperson]', N'SalesmanNumber') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Salesperson]', N'SalespersonNumber') IS NULL)
EXEC sp_rename N'[dbo].[Salesperson].[SalesmanNumber]', N'SalespersonNumber', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Salesperson]', N'Outside') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Salesperson]', N'IsOutsideRep') IS NULL)
EXEC sp_rename N'[dbo].[Salesperson].[Outside]', N'IsOutsideRep', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Salesperson] ALTER COLUMN [IsOutsideRep] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Salesperson] ALTER COLUMN [ImagePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Salesperson] ALTER COLUMN [Description] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Salesperson] on [dbo].[Salesperson]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Salesperson' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [PK_Salesperson] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Salesperson_NaturalKey] on [dbo].[Salesperson]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Salesperson_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Salesperson_NaturalKey] ON [dbo].[Salesperson] ([SalespersonNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[OrderLine]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[OrderLine]', N'AdditionalCharges') IS NULL
ALTER TABLE [dbo].[OrderLine] ADD[AdditionalCharges] [decimal] (18, 5) NOT NULL CONSTRAINT [DF_OrderLine_AdditionalCharges] DEFAULT ((0))
IF COL_LENGTH(N'[dbo].[OrderLine]', N'TaxAmount') IS NULL
ALTER TABLE [dbo].[OrderLine] ADD[TaxAmount] [decimal] (18, 5) NOT NULL CONSTRAINT [DF_OrderLine_TaxAmount] DEFAULT ((0))
IF COL_LENGTH(N'[dbo].[OrderLine]', N'LineGrandTotal') IS NULL
ALTER TABLE [dbo].[OrderLine] ADD[LineGrandTotal] [decimal] (18, 5) NOT NULL CONSTRAINT [DF_OrderLine_TotalLineAmount] DEFAULT ((0))
IF COL_LENGTH(N'[dbo].[OrderLine]', N'WarehouseId') IS NULL
ALTER TABLE [dbo].[OrderLine] ADD[WarehouseId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[OrderLine]', N'OrderLineId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[OrderLine]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[OrderLine].[OrderLineId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[OrderLine] ALTER COLUMN [DueDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[OrderLine] ALTER COLUMN [PromiseDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[OrderLine] ALTER COLUMN [ShipDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[OrderLine] ALTER COLUMN [IsPromotionItem] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_OrderLine] on [dbo].[OrderLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_OrderLine' AND object_id = OBJECT_ID(N'[dbo].[OrderLine]'))
ALTER TABLE [dbo].[OrderLine] ADD CONSTRAINT [PK_OrderLine] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_OrderLine_NaturalKey] on [dbo].[OrderLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderLine_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[OrderLine]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_OrderLine_NaturalKey] ON [dbo].[OrderLine] ([CustomerOrderId], [Line], [Release])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[OrderHistory]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[OrderHistory]', N'OrderHistoryId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[OrderHistory]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[OrderHistory].[OrderHistoryId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[OrderHistory]', N'ModifyDate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[OrderHistory]', N'ModifiedOn') IS NULL)
EXEC sp_rename N'[dbo].[OrderHistory].[ModifyDate]', N'ModifiedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[OrderHistory] ALTER COLUMN [OrderDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[OrderHistory] ALTER COLUMN [ModifiedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_OrderHistory] on [dbo].[OrderHistory]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_OrderHistory' AND object_id = OBJECT_ID(N'[dbo].[OrderHistory]'))
ALTER TABLE [dbo].[OrderHistory] ADD CONSTRAINT [PK_OrderHistory] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_OrderHistory_SearchColumns] on [dbo].[OrderHistory]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderHistory_SearchColumns' AND object_id = OBJECT_ID(N'[dbo].[OrderHistory]'))
CREATE NONCLUSTERED INDEX [IX_OrderHistory_SearchColumns] ON [dbo].[OrderHistory] ([CustomerNumber], [OrderDate]) INCLUDE ([CustomerPO], [CustomerSequence], [ERPOrderNumber], [OrderTotal], [Status], [WebOrderNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_OrderHistory_NaturalKey] on [dbo].[OrderHistory]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderHistory_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[OrderHistory]'))
CREATE NONCLUSTERED INDEX [IX_OrderHistory_NaturalKey] ON [dbo].[OrderHistory] ([ERPOrderNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CustomerOrder]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'DefaultWarehouseId') IS NULL
ALTER TABLE [dbo].[CustomerOrder] ADD[DefaultWarehouseId] [uniqueidentifier] NULL
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'LanguageId') IS NULL
ALTER TABLE [dbo].[CustomerOrder] ADD[LanguageId] [uniqueidentifier] NULL
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'RecalculatePromotions') IS NULL
ALTER TABLE [dbo].[CustomerOrder] ADD[RecalculatePromotions] [bit] NOT NULL CONSTRAINT [DF_CustomerOrder_RecalculatePromotions] DEFAULT ((1))
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'RecalculateShipping') IS NULL
ALTER TABLE [dbo].[CustomerOrder] ADD[RecalculateShipping] [bit] NOT NULL CONSTRAINT [DF_CustomerOrder_RecalculateShipping] DEFAULT ((1))
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'RecalculateTax') IS NULL
ALTER TABLE [dbo].[CustomerOrder] ADD[RecalculateTax] [bit] NOT NULL CONSTRAINT [DF_CustomerOrder_RecalculateTax] DEFAULT ((1))
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'CustomerPOTypeCode') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [CustomerPOTypeCode]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'PriceCode') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [PriceCode]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'CurrencyCode') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [CurrencyCode]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'EndUserType') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [EndUserType]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'Salesman') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [Salesman]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'InvoiceFrequency') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [InvoiceFrequency]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTContact1') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [BTContact1]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTContact2') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [BTContact2]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTContact3') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [BTContact3]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTPhone2') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [BTPhone2]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTPhone3') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [BTPhone3]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTFax') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [BTFax]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTCounty') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [BTCounty]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'STContact1') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [STContact1]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'STContact2') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [STContact2]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'STContact3') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [STContact3]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'STPhone2') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [STPhone2]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'STPhone3') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [STPhone3]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'STFax') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [STFax]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'STCounty') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [STCounty]
IF COL_LENGTH(N'[dbo].[CustomerOrder]', N'LiftGateService') IS NOT NULL
ALTER TABLE [dbo].[CustomerOrder] DROP COLUMN [LiftGateService]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dbo].[CustomerOrder] SET [ConversionRate]=((1)) WHERE [ConversionRate] IS NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'CustomerOrderId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[CustomerOrderId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'Warehouse') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'DefaultWarehouse') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[Warehouse]', N'DefaultWarehouse', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTCompany') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTCompanyName') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[BTCompany]', N'BTCompanyName', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTPhone1') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTPhone') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[BTPhone1]', N'BTPhone', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTZip') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'BTPostalCode') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[BTZip]', N'BTPostalCode', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'STCompany') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'STCompanyName') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[STCompany]', N'STCompanyName', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'STPhone1') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'STPhone') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[STPhone1]', N'STPhone', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'STZip') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'STPostalCode') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[STZip]', N'STPostalCode', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'UserName') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'PlacedByUserName') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[UserName]', N'PlacedByUserName', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'DropShipId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'DropShipCustomerId') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[DropShipId]', N'DropShipCustomerId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'VerificationSent') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'VerificationSentOn') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[VerificationSent]', N'VerificationSentOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrder]', N'PrimarySalesmanId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrder]', N'SalespersonId') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrder].[PrimarySalesmanId]', N'SalespersonId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerOrder] ALTER COLUMN [OrderDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerOrder] ALTER COLUMN [ShipEarly] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerOrder] ALTER COLUMN [ShipPartial] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerOrder] ALTER COLUMN [Residential] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerOrder] ALTER COLUMN [InsideDelivery] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerOrder] ALTER COLUMN [RequestedShipDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerOrder] ALTER COLUMN [VerificationSentOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerOrder] ALTER COLUMN [ConversionRate] [decimal] (18, 5) NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerOrder] ALTER COLUMN [QuoteExpirationDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CustomerOrder] on [dbo].[CustomerOrder]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CustomerOrder' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [PK_CustomerOrder] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CustomerOrder_CustomerId_OrderDate] on [dbo].[CustomerOrder]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerOrder_CustomerId_OrderDate' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]'))
CREATE NONCLUSTERED INDEX [IX_CustomerOrder_CustomerId_OrderDate] ON [dbo].[CustomerOrder] ([CustomerId], [OrderDate] DESC)
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CustomerOrder_NaturalKey] on [dbo].[CustomerOrder]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerOrder_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CustomerOrder_NaturalKey] ON [dbo].[CustomerOrder] ([OrderNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CustomerOrder_Status] on [dbo].[CustomerOrder]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerOrder_Status' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]'))
CREATE NONCLUSTERED INDEX [IX_CustomerOrder_Status] ON [dbo].[CustomerOrder] ([Status])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Currency]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Currency]', N'CurrencyId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Currency]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Currency].[CurrencyId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Currency] ALTER COLUMN [IsDefault] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Currency] on [dbo].[Currency]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Currency' AND object_id = OBJECT_ID(N'[dbo].[Currency]'))
ALTER TABLE [dbo].[Currency] ADD CONSTRAINT [PK_Currency] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Currency_NaturalKey] on [dbo].[Currency]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Currency_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Currency]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Currency_NaturalKey] ON [dbo].[Currency] ([CurrencyCode])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[ReportOrderHistoryView]'
GO
IF OBJECT_ID(N'[dbo].[ReportOrderHistoryView]', 'V') IS NULL
EXEC sp_executesql N'

CREATE VIEW [dbo].[ReportOrderHistoryView]
AS
SELECT        
	''OrderHistory'' AS Source, oh.Id AS Orderid, oh.ERPOrderNumber, oh.WebOrderNumber, oh.OrderDate, oh.Status, 
	oh.CustomerNumber, oh.CustomerSequence, oh.CustomerPO, oh.CurrencyCode, oh.Terms, oh.ShipCode, oh.Salesperson,
	 oh.BTCompanyName, oh.BTAddress1, oh.BTAddress2, oh.BTCity, oh.BTState, oh.BTPostalCode, oh.BTCountry, 
	 oh.STCompanyName, oh.STAddress1, oh.STAddress2, oh.STCity, oh.STState, oh.STPostalCode, oh.STCountry, 
	CASE ISNULL(oh.ConversionRate,0)
		WHEN 0 THEN oh.DiscountAmount
		ELSE oh.DiscountAmount / oh.ConversionRate
	END AS DiscountAmount,
	CASE ISNULL(oh.ConversionRate,0)
		WHEN 0 THEN oh.ShippingAndHandling
		ELSE oh.ShippingAndHandling / oh.ConversionRate
	END AS ShippingAndHandling,
	CASE ISNULL(oh.ConversionRate,0)
		WHEN 0 THEN oh.OtherCharges
		ELSE oh.OtherCharges / oh.ConversionRate
	END AS OtherCharges,
	CASE ISNULL(oh.ConversionRate,0)
		WHEN 0 THEN oh.TaxAmount
		ELSE oh.TaxAmount / oh.ConversionRate
	END AS TaxAmount, 
	oh.ModifiedOn as ''ModifyDate'', 
	CASE ISNULL(oh.ConversionRate,0)
		WHEN 0 THEN oh.ProductTotal
		ELSE oh.ProductTotal  / oh.ConversionRate
	END AS ProductTotal, 
	--oh.ProductTotal, 
	CASE ISNULL(oh.ConversionRate,0)
		WHEN 0 THEN oh.OrderTotal
		ELSE oh.OrderTotal  / oh.ConversionRate
	END AS OrderTotal, 
	--oh.OrderTotal, 
	ISNULL(ws.Name, '''') AS WebSiteName, 
	CASE oh.WebOrderNumber WHEN '''' THEN ''ERP'' ELSE CASE WHEN ws.Name LIKE ''m.%'' THEN ''MOBILE'' ELSE ''WEB'' END END AS OrderType, 
    ISNULL(c.CustomerType, '''') AS CustomerType,
	oh.ConversionRate AS ConversionRate
FROM            
	OrderHistory oh WITH (NOLOCK) LEFT JOIN
    CustomerOrder co WITH (NOLOCK) ON oh.WebOrderNumber = co.OrderNumber LEFT JOIN
    WebSite ws WITH (NOLOCK) ON ws.Id = co.WebSiteId LEFT JOIN
    Customer c WITH (NOLOCK) ON oh.CustomerNumber = c.CustomerNumber AND (c.ParentId IS NULL OR c.ParentId = c.Id)
UNION
SELECT        
	''CustomerOrder'' AS Source, co.id AS Orderid, co.ERPOrderNumber, co.OrderNumber AS WebOrderNumber, co.OrderDate, co.Status, co.CustomerNumber, 
	co.CustomerSequence, co.CustomerPO, curr.CurrencyCode, co.TermsCode AS Terms, co.ShipCode, 
	sls.Code AS Salesperson, co.BTCompanyName, co.BTAddress1, co.BTAddress2, co.BTCity, co.BTState, 
	co.BTPostalCode, co.BTCountry, co.STCompanyName, co.STAddress1, co.STAddress2, 
	co.STCity, co.STState, co.STPostalCode, co.STCountry, 0.00 AS DiscountAmount, 
    0.00 AS ShippingAndHandling, 0.00 AS OtherCharges, 0.00 AS TaxAmount, co.OrderDate AS ModifyDate, 
	CASE ISNULL(co.ConversionRate,0)
		WHEN 0 THEN SUM(ol.QtyOrdered *  ol.ActualPrice)
		ELSE SUM((ol.QtyOrdered * ol.ActualPrice))  / co.ConversionRate
	END AS ProductTotal,
	CASE ISNULL(co.ConversionRate,0)
		WHEN 0 THEN SUM(ol.QtyOrdered *  ol.ActualPrice)
		ELSE SUM((ol.QtyOrdered * ol.ActualPrice))  / co.ConversionRate
	END AS OrderTotal,
	ws.Name AS WebSiteName, 
    CASE WHEN ws.Name LIKE ''m.%'' THEN ''MOBILE'' ELSE ''WEB'' END AS OrderType, ISNULL(c.CustomerType, '''') AS CustomerType,
	co.ConversionRate AS ConversionRate
FROM 
	customerorder co WITH (NOLOCK) 
	LEFT JOIN WebSite ws WITH (NOLOCK) ON co.WebSiteId = ws.Id 
	LEFT JOIN Customer c WITH (NOLOCK) ON co.CustomerNumber = c.CustomerNumber AND (c.ParentId IS NULL OR c.ParentId = c.Id) 
	LEFT JOIN OrderLine ol WITH (NOLOCK) ON co.Id = ol.CustomerOrderId
	LEFT JOIN Salesperson sls WITH (NOLOCK) on co.SalespersonId = sls.id
	LEFT JOIN Currency curr WITH (NOLOCK) on co.CurrencyId = curr.Id
WHERE        
	co.status LIKE ''%Aba%'' AND ol.QtyOrdered > 0
GROUP BY 
	co.Id, co.ErpOrderNumber, co.OrderNumber, co.OrderDate, co.Status, co.CustomerNumber, co.CustomerSequence, 
	co.CustomerPO, 	curr.CurrencyCode, co.TermsCode, co.ShipCode, sls.Code, co.BTCompanyName, co.BTAddress1, 
	co.BTAddress2, co.BTCity, co.BTState, co.BTPostalCode, co.BTCountry, co.STCompanyName, 
    co.STAddress1, co.STAddress2, co.STCity, co.STState, co.STPostalCode, co.STCountry, ws.Name, c.CustomerType,
	 co.ConversionRate


'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[WishList]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[WishList]', N'WishListId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[WishList]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[WishList].[WishListId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_WishList] on [dbo].[WishList]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_WishList' AND object_id = OBJECT_ID(N'[dbo].[WishList]'))
ALTER TABLE [dbo].[WishList] ADD CONSTRAINT [PK_WishList] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_WishList_NaturalKey] on [dbo].[WishList]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_WishList_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[WishList]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_WishList_NaturalKey] ON [dbo].[WishList] ([UserProfileId], [CustomerId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ProductUnitOfMeasure]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ProductUnitOfMeasure]', N'ProductUnitOfMeasureId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ProductUnitOfMeasure]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ProductUnitOfMeasure].[ProductUnitOfMeasureId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ProductUnitOfMeasure] ALTER COLUMN [UnitOfMeasure] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ProductUnitOfMeasure] ALTER COLUMN [Description] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ProductUnitOfMeasure] ALTER COLUMN [RoundingRule] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ProductUnitOfMeasure] ALTER COLUMN [IsDefault] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ProductUnitOfMeasure] on [dbo].[ProductUnitOfMeasure]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ProductUnitOfMeasure' AND object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]'))
ALTER TABLE [dbo].[ProductUnitOfMeasure] ADD CONSTRAINT [PK_ProductUnitOfMeasure] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ProductUnitOfMeasure_NaturalKey] on [dbo].[ProductUnitOfMeasure]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ProductUnitOfMeasure_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ProductUnitOfMeasure_NaturalKey] ON [dbo].[ProductUnitOfMeasure] ([ProductId], [UnitOfMeasure])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PriceMatrix]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PriceMatrix]', N'PriceMatrixId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PriceMatrix]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PriceMatrix].[PriceMatrixId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PriceMatrix]', N'Active') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PriceMatrix]', N'ActivateOn') IS NULL)
EXEC sp_rename N'[dbo].[PriceMatrix].[Active]', N'ActivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PriceMatrix]', N'Deactivate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PriceMatrix]', N'DeactivateOn') IS NULL)
EXEC sp_rename N'[dbo].[PriceMatrix].[Deactivate]', N'DeactivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PriceMatrix] ALTER COLUMN [ActivateOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PriceMatrix] ALTER COLUMN [DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PriceMatrix] on [dbo].[PriceMatrix]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PriceMatrix' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix]'))
ALTER TABLE [dbo].[PriceMatrix] ADD CONSTRAINT [PK_PriceMatrix] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_PriceMatrix_NaturalKey] on [dbo].[PriceMatrix]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PriceMatrix_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[PriceMatrix]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_PriceMatrix_NaturalKey] ON [dbo].[PriceMatrix] ([RecordType], [CurrencyCode], [Warehouse], [UnitOfMeasure], [CustomerKeyPart], [ProductKeyPart], [ActivateOn])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[PriceCalculator_Generic]'
GO
IF OBJECT_ID(N'[dbo].[PriceCalculator_Generic]', 'P') IS NULL
EXEC sp_executesql N'
-- =============================================
-- Author:		Tom Frishberg
-- Create date:	8/3/2011
--
--	Date		Who		What
--	08/04/20??			Default price to ListPrice if nothing calculated and default to BasicListPrice if that doesn''t have anything
--	12/10/2012			Fixed up a little for Jessica specifically
--	01/24/2014	Adam	UOM pricing: if a matrix record is used for a uom, do not multiply the uom.quantity by the price
-- =============================================
CREATE PROCEDURE [dbo].[PriceCalculator_Generic]
  @CustomerId        uniqueidentifier = null,
  @ProductId         uniqueidentifier = null,
  @QtyOrdered        decimal(18,5) = 0,
  @CurrencyCode      nvarchar(50) = '''',
  @Warehouse         nvarchar(50) = '''',
  @UnitOfMeasure     nvarchar(50) = '''',
  @PricingDate       datetime = null,
  @RegularPrice      tinyint = 0,  -- if 1 return price without sale or customer pricing  
  @Price             decimal(18,5) OUTPUT,
  @IsSalePrice       tinyint OUTPUT,  -- only valid if ReturnListPrice = 0
  @Debug		     tinyint = 0
AS
BEGIN 

  DECLARE
    @PriceMatrixId      uniqueidentifier,
    @SalePrice          decimal(18,5),
    @SaleStartDate      datetime,
    @SaleEndDate        datetime,
    @BasicListPrice     decimal(18,5),
    @BasicSalePrice     decimal(18,5),
    @BasicSaleStartDate datetime,
    @BasicSaleEndDate   datetime,
    @ListPrice          decimal(18,5),
    @UnitCost           decimal(18,5),
    @ProductPriceCode   nvarchar(50),
    @ProductUM          nvarchar(50),
    @ProductVendorId    uniqueidentifier,
    @CustomerPriceCode  nvarchar(50),
    @ParentCustomerId   uniqueidentifier,
    @RecordType         nvarchar(50),
    @CustomerKeyPart    nvarchar(50),
    @ProductKeyPart     nvarchar(50),
    @CalcFlags          nvarchar(50),
    @BrkQty1            decimal(18,5),
    @BrkQty2            decimal(18,5),
    @BrkQty3            decimal(18,5),
    @BrkQty4            decimal(18,5),
    @BrkQty5            decimal(18,5),
    @BrkQty6            decimal(18,5),
    @BrkQty7            decimal(18,5),
    @BrkQty8            decimal(18,5),
    @BrkQty9            decimal(18,5),
    @BrkQty10           decimal(18,5),
    @BrkQty11           decimal(18,5),
    @PriceBasis1        nvarchar(50),
    @PriceBasis2        nvarchar(50),
    @PriceBasis3        nvarchar(50),
    @PriceBasis4        nvarchar(50),
    @PriceBasis5        nvarchar(50),
    @PriceBasis6        nvarchar(50),
    @PriceBasis7        nvarchar(50),
    @PriceBasis8        nvarchar(50),
    @PriceBasis9        nvarchar(50),
    @PriceBasis10       nvarchar(50),
    @PriceBasis11       nvarchar(50),
    @AdjType1           nvarchar(50),
    @AdjType2           nvarchar(50),
    @AdjType3           nvarchar(50),
    @AdjType4           nvarchar(50),
    @AdjType5           nvarchar(50),
    @AdjType6           nvarchar(50),
    @AdjType7           nvarchar(50),
    @AdjType8           nvarchar(50),
    @AdjType9           nvarchar(50),
    @AdjType10          nvarchar(50),
    @AdjType11          nvarchar(50),
    @Amount1            decimal(18,5),
    @Amount2            decimal(18,5),
    @Amount3            decimal(18,5),
    @Amount4            decimal(18,5),
    @Amount5            decimal(18,5),
    @Amount6            decimal(18,5),
    @Amount7            decimal(18,5),
    @Amount8            decimal(18,5),
    @Amount9            decimal(18,5),
    @Amount10           decimal(18,5),
    @Amount11           decimal(18,5),
    @AltAmount1         decimal(18,5),    
    @AltAmount2         decimal(18,5),    
    @AltAmount3         decimal(18,5),    
    @AltAmount4         decimal(18,5),    
    @AltAmount5         decimal(18,5),    
    @AltAmount6         decimal(18,5),    
    @AltAmount7         decimal(18,5),    
    @AltAmount8         decimal(18,5),    
    @AltAmount9         decimal(18,5),    
    @AltAmount10        decimal(18,5),    
    @AltAmount11        decimal(18,5),
    @Loop               int,
    @CurAmount          decimal(18,5),
    @CurAltAmount       decimal(18,5),
    @CurBrkQty          decimal(18,5),
    @CurPriceBasis      nvarchar(50),
    @CurAdjType         nvarchar(50),
    @tmpBasisValue      decimal(18,5),
    @tmpPriceBasis      nvarchar(50),
    @UsingBaseUOM		bit,
	@PriceIsOverride	bit = 0

  /* SyteLine-specific variables */
  DECLARE
    @PriceLevel1        decimal(18,5),
    @PriceLevel2        decimal(18,5),
    @PriceLevel3        decimal(18,5),
    @PriceLevel4        decimal(18,5),
    @PriceLevel5        decimal(18,5),
    @PriceLevel6        decimal(18,5)
    
  DECLARE @PriceBreaks TABLE (BreakQty DECIMAL(18,5), Price DECIMAL(18,5))
	

  IF @PricingDate IS NULL
    SET @PricingDate = dateadd(dd,0,datediff(dd,0,getdate()))
  SET @IsSalePrice = 0

  /* If they want list price, whack the customer reference */
  IF @RegularPrice <> 0 
    SET @CustomerId = null
    
  /* First get the product information */
  IF @ProductID IS null
  BEGIN
    print ''Error - no product selected''
    RETURN 99
  END  
 
  SELECT 
    @ProductPriceCode = PriceCode, 
    @ProductUM = UnitOfMeasure,
    @UnitCost = UnitCost,
    @ProductVendorId = VendorId,
    @BasicListPrice = BasicListPrice,
    @BasicSalePrice = BasicSalePrice,
    @BasicSaleStartDate = BasicSaleStartDate,
    @BasicSaleEndDate = BasicSaleEndDate
  FROM Product (NOLOCK)
  WHERE Id = @ProductId


  IF IsNull(@UnitOfMeasure,'''') = ''''
    SET @UnitOfMeasure = @ProductUM
    
  SET @UsingBaseUOM = 1
  IF @UnitOfMeasure <> @ProductUM
	SET @UsingBaseUOM = 0
	
 IF @Debug = 1
    select @ProductId as ''ProductID'',@UnitCost as ''Unit Cost'', @CurrencyCode as ''Curr'',
    @ProductUM as ''UM'',@CustomerId as ''CustId'',@PricingDate as ''PricingDate''
	

  /* Get List Price for basis calculations */
  SELECT 
    @ListPrice = Amount01,
    @PriceLevel1 = AltAmount01,
    @PriceLevel2 = AltAmount02,
    @PriceLevel3 = AltAmount03,
    @PriceLevel4 = AltAmount04,
    @PriceLevel5 = AltAmount05,
    @PriceLevel6 = AltAmount06,
    
    -- To Capture Price Breaks
	@BrkQty1 = BreakQty01,
	@BrkQty2 = BreakQty02,
	@BrkQty3 = BreakQty03,
	@BrkQty4 = BreakQty04,
	@BrkQty5 = BreakQty05,
	@BrkQty6 = BreakQty06,
	@BrkQty7 = BreakQty07,
	@BrkQty8 = BreakQty08,
	@BrkQty9 = BreakQty09,
	@BrkQty10 = BreakQty10,
	@BrkQty11 = BreakQty11,
	@Amount1 = Amount01,
	@Amount2 = Amount02,
	@Amount3 = Amount03,
	@Amount4 = Amount04,
	@Amount5 = Amount05,
	@Amount6 = Amount06,
	@Amount7 = Amount07,
	@Amount8 = Amount08,
	@Amount9 = Amount09,
	@Amount10 = Amount10,
	@Amount11 = Amount11

  FROM PriceMatrix (NOLOCK)
  WHERE
    RecordType = ''Product'' AND
    CurrencyCode = @CurrencyCode AND
    Warehouse = @Warehouse AND
    UnitOfMeasure = @UnitOfMeasure AND
    CustomerKeyPart = '''' AND
    ProductKeyPart = @ProductId AND
    ActivateOn <= @PricingDate AND
    (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)

  -- Capture Price Breaks
  INSERT INTO @PriceBreaks SELECT @BrkQty1, @Amount1
  IF @BrkQty2 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty2, @Amount2
  IF @BrkQty3 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty3, @Amount3
  IF @BrkQty4 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty4, @Amount4
  IF @BrkQty5 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty5, @Amount5
  IF @BrkQty6 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty6, @Amount6
  IF @BrkQty7 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty7, @Amount7
  IF @BrkQty8 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty8, @Amount8
  IF @BrkQty9 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty9, @Amount9
  IF @BrkQty10 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty10, @Amount10
  IF @BrkQty11 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty11, @Amount11
      
  /* Next get the customer information, if any */
  IF @CustomerId is not null
  BEGIN
    SELECT
      @CustomerPriceCode = PriceCode,
      @ParentCustomerId = ParentId
    FROM Customer (NOLOCK)
    WHERE Id = @CustomerId
  END


  /* Now try and find which record will hold the key */
  SET @PriceMatrixId = NULL
  
  /* Customer/Product */
  IF @PriceMatrixId IS NULL AND @CustomerId is not null
  BEGIN
    SELECT @PriceMatrixID = ID
    FROM PriceMatrix (NOLOCK) 
    WHERE
      RecordType = ''Customer/Product'' AND
      CurrencyCode = @CurrencyCode AND
      Warehouse = @Warehouse AND
      UnitOfMeasure = @UnitOfMeasure AND
      CustomerKeyPart = @CustomerId AND
      ProductKeyPart = @ProductId AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
  END

  /* Customer/Product Price Code */
  IF @PriceMatrixId IS NULL AND @CustomerId  is not null
  BEGIN
    SELECT @PriceMatrixID = ID
    FROM PriceMatrix (NOLOCK) 
    WHERE
      RecordType = ''Customer/Product Price Code'' AND
      CurrencyCode = @CurrencyCode AND
      Warehouse = @Warehouse AND
      --UnitOfMeasure = @UnitOfMeasure AND  -- can''t use UM without specific product
      CustomerKeyPart = @CustomerId AND
      ProductKeyPart =  @ProductPriceCode AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
  END

  /* Parent Customer/Product */
  IF @PriceMatrixId IS NULL AND @ParentCustomerId  is not null
  BEGIN
    SELECT @PriceMatrixID = ID
    FROM PriceMatrix (NOLOCK) 
    WHERE
      RecordType = ''Customer/Product'' AND
      CurrencyCode = @CurrencyCode AND
      Warehouse = @Warehouse AND
      UnitOfMeasure = @UnitOfMeasure AND
      CustomerKeyPart = @ParentCustomerId AND
      ProductKeyPart = @ProductId AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
  END

  /* Parent Customer/Product Price Code */
  IF @PriceMatrixId IS NULL AND @ParentCustomerId is not null
  BEGIN
    SELECT @PriceMatrixID = ID
    FROM PriceMatrix (NOLOCK) 
    WHERE
      RecordType = ''Customer/Product Price Code'' AND
      CurrencyCode = @CurrencyCode AND
      Warehouse = @Warehouse AND
      --UnitOfMeasure = @UnitOfMeasure AND  -- no UM withouth specific product
      CustomerKeyPart = @ParentCustomerId AND
      ProductKeyPart =  @ProductPriceCode AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
  END

  /* Customer Price Code/Product - don''t see this type in SL but no harm in looking for it */
  IF @PriceMatrixId IS NULL AND @CustomerId  is not null 
     AND @CustomerPriceCode <> ''''
  BEGIN
    SELECT @PriceMatrixID = ID
    FROM PriceMatrix (NOLOCK) 
    WHERE
      RecordType = ''Customer Price Code/Product'' AND
      CurrencyCode = @CurrencyCode AND
      Warehouse = @Warehouse AND
      UnitOfMeasure = @UnitOfMeasure AND
      CustomerKeyPart = @CustomerPriceCode AND
      ProductKeyPart = @ProductId AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
  END        

  /* Customer Price Code/Product Price Code */
  IF @PriceMatrixId IS NULL AND @CustomerId  is not null 
     AND @CustomerPriceCode <> ''''
     AND @ProductPriceCode <> ''''
  BEGIN
    SELECT @PriceMatrixID = ID
    FROM PriceMatrix (NOLOCK) 
    WHERE
      RecordType = ''Customer Price Code/Product Price Code'' AND
      CurrencyCode = @CurrencyCode AND
      Warehouse = @Warehouse AND
   --   UnitOfMeasure = @UnitOfMeasure AND  -- no UM without specific product
      CustomerKeyPart = @CustomerPriceCode AND
      ProductKeyPart = @ProductPriceCode AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
  END       

  /* Customer */
  IF @PriceMatrixId IS NULL AND @CustomerId  is not null 
  BEGIN
    SELECT @PriceMatrixID = ID
    FROM PriceMatrix (NOLOCK) 
    WHERE
      RecordType = ''Customer'' AND
      CurrencyCode = @CurrencyCode AND
   --   Warehouse = @Warehouse AND
   --   UnitOfMeasure = @UnitOfMeasure AND  -- no UM without specific product
      CustomerKeyPart = @CustomerId AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
  END       

  /* Customer Price Code */
  IF @PriceMatrixId IS NULL AND @CustomerId  is not null 
     AND @CustomerPriceCode <> ''''
  BEGIN
    SELECT @PriceMatrixID = ID
    FROM PriceMatrix (NOLOCK) 
    WHERE
      RecordType = ''Customer Price Code'' AND
      CurrencyCode = @CurrencyCode AND
      Warehouse = @Warehouse AND
   --   UnitOfMeasure = @UnitOfMeasure AND  -- no UM without specific product
      CustomerKeyPart = @CustomerPriceCode AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
  END       

  /* Product Price Code */
  IF @PriceMatrixId IS NULL AND @ProductPriceCode <> ''''
  BEGIN
    SELECT @PriceMatrixID = ID
    FROM PriceMatrix (NOLOCK) 
    WHERE
      RecordType = ''Product Price Code'' AND
      CurrencyCode = @CurrencyCode AND
      Warehouse = @Warehouse AND
      UnitOfMeasure = @UnitOfMeasure AND
      ProductKeyPart = @ProductPriceCode AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
  END       

  /* Product Base Record - grabbing this record if nothing else grabbed */
  IF @PriceMatrixId IS NULL
  BEGIN
    SELECT @PriceMatrixID = ID
    FROM PriceMatrix (NOLOCK) 
    WHERE
      RecordType = ''Product'' AND
      CurrencyCode = @CurrencyCode AND
      Warehouse = @Warehouse AND
      UnitOfMeasure = @UnitOfMeasure AND
      CustomerKeyPart = '''' AND
      ProductKeyPart = @ProductId AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
  END    
  
  IF @Debug = 1 SELECT @PriceMatrixId as ''Selected Matrix ID''

  /* Check to see if we have a valid record and read it in */
  IF @PriceMatrixId IS NULL
  BEGIN
    SET @Price = @ListPrice
  END

  ELSE BEGIN
    SELECT 
      @RecordType = RecordType,
      @BrkQty1 = BreakQty01,
      @BrkQty2 = BreakQty02,
      @BrkQty3 = BreakQty03,
      @BrkQty4 = BreakQty04,
      @BrkQty5 = BreakQty05,
      @BrkQty6 = BreakQty06,
      @BrkQty7 = BreakQty07,
      @BrkQty8 = BreakQty08,
      @BrkQty9 = BreakQty09,
      @BrkQty10 = BreakQty10,
      @BrkQty11 = BreakQty11,
      @PriceBasis1 = PriceBasis01,
      @PriceBasis2 = PriceBasis02,
      @PriceBasis3 = PriceBasis03,
      @PriceBasis4 = PriceBasis04,
      @PriceBasis5 = PriceBasis05,
      @PriceBasis6 = PriceBasis06,
      @PriceBasis7 = PriceBasis07,
      @PriceBasis8 = PriceBasis08,
      @PriceBasis9 = PriceBasis09,
      @PriceBasis10 = PriceBasis10,
      @PriceBasis11 = PriceBasis11,
      @AdjType1 = AdjustmentType01,
      @AdjType2 = AdjustmentType02,
      @AdjType3 = AdjustmentType03,
      @AdjType4 = AdjustmentType04,
      @AdjType5 = AdjustmentType05,
      @AdjType6 = AdjustmentType06,
      @AdjType7 = AdjustmentType07,
      @AdjType8 = AdjustmentType08,
      @AdjType9 = AdjustmentType09,
      @AdjType10 = AdjustmentType10,
      @AdjType11 = AdjustmentType11,
      @Amount1 = Amount01,
      @Amount2 = Amount02,
      @Amount3 = Amount03,
      @Amount4 = Amount04,
      @Amount5 = Amount05,
      @Amount6 = Amount06,
      @Amount7 = Amount07,
      @Amount8 = Amount08,
      @Amount9 = Amount09,
      @Amount10 = Amount10,
      @Amount11 = Amount11,
      @AltAmount1 = AltAmount01,
      @AltAmount2 = AltAmount02,
      @AltAmount3 = AltAmount03,
      @AltAmount4 = AltAmount04,
      @AltAmount5 = AltAmount05,
      @AltAmount6 = AltAmount06,
      @AltAmount7 = AltAmount07,
      @AltAmount8 = AltAmount08,
      @AltAmount9 = AltAmount09,
      @AltAmount10 = AltAmount10,
      @AltAmount11 = AltAmount11 
    FROM PriceMatrix (NOLOCK)
    WHERE Id = @PriceMatrixId


    /* And now the ugly stuff - traversing through the given record and figuring out price */
    SELECT
      @CurAmount = @Amount1,
      @CurBrkQty = @BrkQty1,
      @CurPriceBasis = @PriceBasis1,
      @CurAdjType = @AdjType1

    IF @QtyOrdered >= @BrkQty2 AND @BrkQty2 > 0
      SELECT
        @CurAmount = @Amount2,
        @CurBrkQty = @BrkQty2,
        @CurPriceBasis = @PriceBasis2,
        @CurAdjType = @AdjType2

    IF @QtyOrdered >= @BrkQty3 AND @BrkQty3 > 0
      SELECT
        @CurAmount = @Amount3,
        @CurBrkQty = @BrkQty3,
        @CurPriceBasis = @PriceBasis3,
        @CurAdjType = @AdjType3

    IF @QtyOrdered >= @BrkQty4 AND @BrkQty4 > 0
      SELECT
        @CurAmount = @Amount4,
        @CurBrkQty = @BrkQty4,
        @CurPriceBasis = @PriceBasis4,
        @CurAdjType = @AdjType4

    IF @QtyOrdered >= @BrkQty5 AND @BrkQty5 > 0
      SELECT
        @CurAmount = @Amount5,
        @CurBrkQty = @BrkQty5,
        @CurPriceBasis = @PriceBasis5,
        @CurAdjType = @AdjType5

    IF @QtyOrdered >= @BrkQty6 AND @BrkQty6 > 0
      SELECT
        @CurAmount = @Amount6,
        @CurBrkQty = @BrkQty6,
        @CurPriceBasis = @PriceBasis6,
        @CurAdjType = @AdjType6

    IF @QtyOrdered >= @BrkQty7 AND @BrkQty7 > 0
      SELECT
        @CurAmount = @Amount7,
        @CurBrkQty = @BrkQty7,
        @CurPriceBasis = @PriceBasis7,
        @CurAdjType = @AdjType7

    IF @QtyOrdered >= @BrkQty8 AND @BrkQty8 > 0
      SELECT
        @CurAmount = @Amount8,
        @CurBrkQty = @BrkQty8,
        @CurPriceBasis = @PriceBasis8,
        @CurAdjType = @AdjType8

    IF @QtyOrdered >= @BrkQty9 AND @BrkQty9 > 0
      SELECT
        @CurAmount = @Amount9,
        @CurBrkQty = @BrkQty9,
        @CurPriceBasis = @PriceBasis9,
        @CurAdjType = @AdjType9

    IF @QtyOrdered >= @BrkQty10 AND @BrkQty10 > 0
      SELECT
        @CurAmount = @Amount10,
        @CurBrkQty = @BrkQty10,
        @CurPriceBasis = @PriceBasis10,
        @CurAdjType = @AdjType10

    IF @QtyOrdered >= @BrkQty11 AND @BrkQty11 > 0
      SELECT
        @CurAmount = @Amount11,
        @CurBrkQty = @BrkQty11,
        @CurPriceBasis = @PriceBasis11,
        @CurAdjType = @AdjType11


    /* Set price basis level */
    SET @tmpBasisValue = 0
    IF @CurPriceBasis = ''C'' SET @tmpBasisValue = @UnitCost
    IF @CurPriceBasis = ''M'' SET @tmpBasisValue = @UnitCost -- margin
    IF @CurPriceBasis = ''MU'' SET @tmpBasisValue = @UnitCost -- markup (mu/vmu)
    IF @CurPriceBasis = ''L'' SET @tmpBasisValue = @ListPrice
    IF @CurPriceBasis = ''P1'' SET @tmpBasisValue = @PriceLevel1
    IF @CurPriceBasis = ''P2'' SET @tmpBasisValue = @PriceLevel2
    IF @CurPriceBasis = ''P3'' SET @tmpBasisValue = @PriceLevel3
    IF @CurPriceBasis = ''P4'' SET @tmpBasisValue = @PriceLevel4
    IF @CurPriceBasis = ''P5'' SET @tmpBasisValue = @PriceLevel5
    IF @CurPriceBasis = ''P6'' SET @tmpBasisValue = @PriceLevel6

	IF @Debug = 1
	SELECT 
		@RecordType ''RecordType'', 
		@tmpBasisValue ''TmpBasisValue'',
		@ListPrice ''ListPrice'',
		@CurAdjType ''CurAdjType'', 
		@CurPriceBasis ''PriceBasis'', 
		@UnitCost ''Cost'', 
		@CurAmount ''CurAmount'',
		@Price ''Price''

    /* Calculate actual price based on current break */
    
    /* Override Price */
    IF @CurPriceBasis = ''O'' AND @CurAdjType = ''A''
    BEGIN
      SET @Price = @CurAmount
	  SET @PriceIsOverride = 1
      
      -- Capture Price Breaks
      DELETE FROM @PriceBreaks
      INSERT INTO @PriceBreaks SELECT @BrkQty1, @Amount1
      IF @BrkQty2 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty2, @Amount2
      IF @BrkQty3 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty3, @Amount3
      IF @BrkQty4 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty4, @Amount4
      IF @BrkQty5 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty5, @Amount5
      IF @BrkQty6 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty6, @Amount6
      IF @BrkQty7 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty7, @Amount7
      IF @BrkQty8 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty8, @Amount8
      IF @BrkQty9 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty9, @Amount9
      IF @BrkQty10 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty10, @Amount10
      IF @BrkQty11 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty11, @Amount11

	END
    /* Non-derived-Based types - always adds */
    IF @CurPriceBasis IN (''C'',''MU'',''L'',''P1'',''P2'',''P3'',''P4'',''P5'',''P6'')
    BEGIN
      IF @CurAdjType = ''A''
        SET @Price = @tmpBasisValue + @CurAmount
      IF @CurAdjType = ''P''
        SET @Price = @tmpBasisValue * (1 + @CurAmount / 100)
        
      -- Capture Price Breaks
      DELETE FROM @PriceBreaks
      INSERT INTO @PriceBreaks SELECT @BrkQty1, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount1 ELSE @tmpBasisValue * (1 + @Amount1 / 100) END
      IF @BrkQty2 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty2, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount2 ELSE @tmpBasisValue * (1 + @Amount2 / 100) END
      IF @BrkQty3 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty3, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount3 ELSE @tmpBasisValue * (1 + @Amount3 / 100) END
      IF @BrkQty4 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty4, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount4 ELSE @tmpBasisValue * (1 + @Amount4 / 100) END
      IF @BrkQty5 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty5, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount5 ELSE @tmpBasisValue * (1 + @Amount5 / 100) END
      IF @BrkQty6 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty6, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount6 ELSE @tmpBasisValue * (1 + @Amount6 / 100) END
      IF @BrkQty7 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty7, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount7 ELSE @tmpBasisValue * (1 + @Amount7 / 100) END
      IF @BrkQty8 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty8, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount8 ELSE @tmpBasisValue * (1 + @Amount8 / 100) END
      IF @BrkQty9 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty9, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount9 ELSE @tmpBasisValue * (1 + @Amount9 / 100) END
      IF @BrkQty10 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty10, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount10 ELSE @tmpBasisValue * (1 + @Amount10 / 100) END
      IF @BrkQty11 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty11, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount11 ELSE @tmpBasisValue * (1 + @Amount11 / 100) END

    END -- non-derived

    /* Margin */
    IF @CurPriceBasis = ''M''
    BEGIN
      IF @CurAdjType = ''A''
        SET @Price = @CurAmount + @tmpBasisValue
      IF @CurAdjType = ''P''
        SET @Price = @tmpBasisValue / (1 - @CurAmount / 100) 

      -- Capture Price Breaks
      DELETE FROM @PriceBreaks
      INSERT INTO @PriceBreaks SELECT @BrkQty1, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount1 ELSE @tmpBasisValue / (1 - @Amount1 / 100) END
      IF @BrkQty2 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty2, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount2 ELSE @tmpBasisValue / (1 - @Amount2 / 100) END
      IF @BrkQty3 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty3, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount3 ELSE @tmpBasisValue / (1 - @Amount3 / 100) END
      IF @BrkQty4 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty4, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount4 ELSE @tmpBasisValue / (1 - @Amount4 / 100) END
      IF @BrkQty5 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty5, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount5 ELSE @tmpBasisValue / (1 - @Amount5 / 100) END
      IF @BrkQty6 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty6, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount6 ELSE @tmpBasisValue / (1 - @Amount6 / 100) END
      IF @BrkQty7 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty7, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount7 ELSE @tmpBasisValue / (1 - @Amount7 / 100) END
      IF @BrkQty8 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty8, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount8 ELSE @tmpBasisValue / (1 - @Amount8 / 100) END
      IF @BrkQty9 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty9, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount9 ELSE @tmpBasisValue / (1 - @Amount9 / 100) END
      IF @BrkQty10 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty10, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount10 ELSE @tmpBasisValue / (1 - @Amount10 / 100) END
      IF @BrkQty11 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty11, CASE WHEN @CurAdjType = ''A'' THEN @tmpBasisValue + @Amount11 ELSE @tmpBasisValue / (1 - @Amount11 / 100) END

    END
/*
	SELECT 
		@RecordType ''RecordType'', 
		@tmpBasisValue ''TmpBasisValue'',
		@ListPrice ''ListPrice'',
		@CurAdjType ''CurAdjType'', 
		@CurPriceBasis ''PriceBasis'', 
		@UnitCost ''Cost'', 
		@CurAmount ''CurAmount'',
		@Price ''Price''
		*/

  END -- Price Matrix record found


  -- Now go for Sale Price - assumed to be all price overrides
  IF @RegularPrice = 0
  BEGIN
    
	BEGIN
      SET @PriceMatrixId = NULL
      SET @SalePrice = 0
      SELECT 
        @PriceMatrixId = Id,
        @BrkQty1 = BreakQty01,
        @BrkQty2 = BreakQty02,
        @BrkQty3 = BreakQty03,
        @BrkQty4 = BreakQty04,
        @BrkQty5 = BreakQty05,
        @BrkQty6 = BreakQty06,
        @BrkQty7 = BreakQty07,
        @BrkQty8 = BreakQty08,
        @BrkQty9 = BreakQty09,
        @BrkQty10 = BreakQty10,
        @BrkQty11 = BreakQty11,
        @Amount1 = Amount01,
        @Amount2 = Amount02,
        @Amount3 = Amount03,
        @Amount4 = Amount04,
        @Amount5 = Amount05,
        @Amount6 = Amount06,
        @Amount7 = Amount07,
        @Amount8 = Amount08,
        @Amount9 = Amount09,
        @Amount10 = Amount10,
        @Amount11 = Amount11
      FROM PriceMatrix (NOLOCK) 
      WHERE
        RecordType = ''Product Sale'' AND
        CurrencyCode = @CurrencyCode AND
        Warehouse = @Warehouse AND
        UnitOfMeasure = @UnitOfMeasure AND
        CustomerKeyPart = '''' AND
        ProductKeyPart = @ProductId AND
        ActivateOn <= @PricingDate AND
        (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)

      IF @PriceMatrixId IS NOT NULL
      BEGIN
        IF @QtyOrdered >= @BrkQty1                    SET @SalePrice = @Amount1
        IF @QtyOrdered >= @BrkQty2  AND @BrkQty2  > 0 SET @SalePrice = @Amount2
        IF @QtyOrdered >= @BrkQty3  AND @BrkQty3  > 0 SET @SalePrice = @Amount3
        IF @QtyOrdered >= @BrkQty4  AND @BrkQty4  > 0 SET @SalePrice = @Amount4
        IF @QtyOrdered >= @BrkQty5  AND @BrkQty5  > 0 SET @SalePrice = @Amount5
        IF @QtyOrdered >= @BrkQty6  AND @BrkQty6  > 0 SET @SalePrice = @Amount6
        IF @QtyOrdered >= @BrkQty7  AND @BrkQty7  > 0 SET @SalePrice = @Amount7
        IF @QtyOrdered >= @BrkQty8  AND @BrkQty8  > 0 SET @SalePrice = @Amount8
        IF @QtyOrdered >= @BrkQty9  AND @BrkQty9  > 0 SET @SalePrice = @Amount9
        IF @QtyOrdered >= @BrkQty10 AND @BrkQty10 > 0 SET @SalePrice = @Amount10
        IF @QtyOrdered >= @BrkQty11 AND @BrkQty11 > 0 SET @SalePrice = @Amount11    

		-- Capture Price Breaks
		DELETE FROM @PriceBreaks
		INSERT INTO @PriceBreaks SELECT @BrkQty1, @Amount1
		IF @BrkQty2 > 0 AND @Amount2 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty2, @Amount2
		IF @BrkQty3 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty3, @Amount3
		IF @BrkQty4 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty4, @Amount4
		IF @BrkQty5 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty5, @Amount5
		IF @BrkQty6 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty6, @Amount6
		IF @BrkQty7 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty7, @Amount7
		IF @BrkQty8 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty8, @Amount8
		IF @BrkQty9 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty9, @Amount9
		IF @BrkQty10 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty10, @Amount10
		IF @BrkQty11 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty11, @Amount11

      END
      ELSE
      BEGIN
		IF @BasicSaleStartDate <= @PricingDate AND @BasicSaleEndDate IS NULL OR @BasicSaleEndDate > @PricingDate
			SET @SalePrice = @BasicSalePrice
      END

    END --  Standard vs Vendor MU sales price

    -- Check for 0 pricing
    SET @Price = ISNULL(@Price,0)
    IF @Price <= 0 SET @Price = ISNULL(@ListPrice,0)
    IF @Price <= 0 AND @UsingBaseUOM = 1 SET @Price = ISNULL(@BasicListPrice,0)

    IF @SalePrice > 0 AND @SalePrice < @Price
      SELECT
        @Price = @SalePrice, -- if it''s actually less, set it
        @IsSalePrice = 1

  END -- RegularPrice=0
  
  ELSE BEGIN
    -- Check for 0 pricing
    SET @Price = ISNULL(@Price,0)
    IF @Price <= 0 SET @Price = ISNULL(@ListPrice,0)
    IF @Price <= 0 AND @UsingBaseUOM = 1 SET @Price = ISNULL(@BasicListPrice,0)
  END

  IF (@UsingBaseUOM = 0 AND @PriceIsOverride = 0)
  BEGIN
	DECLARE @QtyPerBase DECIMAL
	SELECT @QtyPerBase = QtyPerBaseUnitOfMeasure FROM ProductUnitOfMeasure (NOLOCK) WHERE ProductId = @ProductId AND UnitOfMeasure = @UnitOfMeasure
	IF NOT @QtyPerBase IS NULL
	BEGIN
 		SET @Price = @Price * @QtyPerBase
 		UPDATE @PriceBreaks SET Price = Price * @QtyPerBase
 	END
  END
  
  SELECT * FROM @PriceBreaks

  -- Output parameters do not appear to work if a stored proc returns a result set, so we are just going to return two result sets to get the data back
  SELECT @Price AS Price, @IsSalePrice AS IsSalePrice

END -- End of procedure
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[WebPageContent]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[WebPageContent]', N'WebPageContentId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[WebPageContent]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[WebPageContent].[WebPageContentId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[WebPageContent]', N'MetaTags') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[WebPageContent]', N'MetaKeywords') IS NULL)
EXEC sp_rename N'[dbo].[WebPageContent].[MetaTags]', N'MetaKeywords', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebPageContent] ALTER COLUMN [OverrideParent] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_WebPageContent] on [dbo].[WebPageContent]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_WebPageContent' AND object_id = OBJECT_ID(N'[dbo].[WebPageContent]'))
ALTER TABLE [dbo].[WebPageContent] ADD CONSTRAINT [PK_WebPageContent] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[WebPageContent_After_Delete] on [dbo].[WebPageContent]'
GO
IF OBJECT_ID(N'[dbo].[WebPageContent_After_Delete]', 'TR') IS NULL
EXEC sp_executesql N'CREATE TRIGGER [dbo].[WebPageContent_After_Delete]
   ON  [dbo].[WebPageContent]
   AFTER DELETE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
    DELETE cm FROM ContentManager cm INNER JOIN DELETED d ON d.ContentManagerId = cm.Id

END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ApplicationSetting]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ApplicationSetting]', N'ApplicationSettingId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ApplicationSetting]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ApplicationSetting].[ApplicationSettingId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ApplicationSetting] ALTER COLUMN [Value] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ApplicationSetting] ALTER COLUMN [Description] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ApplicationSetting] on [dbo].[ApplicationSetting]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ApplicationSetting' AND object_id = OBJECT_ID(N'[dbo].[ApplicationSetting]'))
ALTER TABLE [dbo].[ApplicationSetting] ADD CONSTRAINT [PK_ApplicationSetting] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[PriceCalculator_Epicor9Vantage]'
GO
IF OBJECT_ID(N'[dbo].[PriceCalculator_Epicor9Vantage]', 'P') IS NULL
EXEC sp_executesql N'
-- Price Calculator - Epicor9Vantage (also used for Vantage803)
-- Created: 6/13/11, tjf
-- 1/20/12, tjf, Problem with price list seq > 10, convert to INT
-- 2/27/12, tjf, Defaulting customer group if no customer passed in
-- 3/7/12,  tjf, Saving @QtyPriceMatrixID for breaks; only getting disct/qty brk
--				   from a single record; scan further for base price only - rework for secondary cursor
-- 2/6/13,  pwg, Fix output format to make this compatible with isc 3.4.
-- 5/22/13, jel, Fix to have percent off breaks return appropriate amount and have breaks start with base price at 1 (CW 42523)
-- 7/14/14, tjf, Somehow missed % off list price situation - adding back in
-- 
-- This routine will first construct a temp table in order of the price lists to review
-- and then go through each one until if finds the appropriate data (basically PriceBasis and
-- AdjustmentAmount) to calculate from

CREATE PROCEDURE [dbo].[PriceCalculator_Epicor9Vantage]
  @CustomerId        uniqueidentifier = null,
  @ProductId         uniqueidentifier = null,
  @QtyOrdered        decimal(18,5) = 0,
  @CurrencyCode      nvarchar(50) = '''',
  @Warehouse         nvarchar(50) = '''',
  @UnitOfMeasure     nvarchar(50) = '''',
  @PricingDate       datetime = null,
  @RegularPrice      tinyint = 0,  -- if 1 return price without sale or customer pricing  
  @Price             decimal(18,5) OUTPUT,
  @IsSalePrice       tinyint OUTPUT  -- only valid if ReturnListPrice = 0
AS
BEGIN 

  DECLARE
    @PriceMatrixId      uniqueidentifier,
    @SalePrice          decimal(18,5),
    @SaleStartDate      datetime,
    @SaleEndDate        datetime,
    @ListPrice          decimal(18,5),
    @BasicListPrice     decimal(18,5),
    @UnitCost           decimal(18,5),
    @ProductCode        nvarchar(50),
    @ProductUM          nvarchar(50),
    @ProductVendorId    uniqueidentifier,
    @CustomerType       nvarchar(50),
    @ParentCustomerId   uniqueidentifier,
    @RecordType         nvarchar(50),
    @CustomerKeyPart    nvarchar(50),
    @ProductKeyPart     nvarchar(50),
    @CalcFlags          nvarchar(50),
    @BrkQty1            decimal(18,5),
    @BrkQty2            decimal(18,5),
    @BrkQty3            decimal(18,5),
    @BrkQty4            decimal(18,5),
    @BrkQty5            decimal(18,5),
    @BrkQty6            decimal(18,5),
    @BrkQty7            decimal(18,5),
    @BrkQty8            decimal(18,5),
    @BrkQty9            decimal(18,5),
    @BrkQty10           decimal(18,5),
    @BrkQty11           decimal(18,5),
    @PriceBasis1        nvarchar(50),
    @PriceBasis2        nvarchar(50),
    @PriceBasis3        nvarchar(50),
    @PriceBasis4        nvarchar(50),
    @PriceBasis5        nvarchar(50),
    @PriceBasis6        nvarchar(50),
    @PriceBasis7        nvarchar(50),
    @PriceBasis8        nvarchar(50),
    @PriceBasis9        nvarchar(50),
    @PriceBasis10       nvarchar(50),
    @PriceBasis11       nvarchar(50),
    @AdjType1           nvarchar(50),
    @AdjType2           nvarchar(50),
    @AdjType3           nvarchar(50),
    @AdjType4           nvarchar(50),
    @AdjType5           nvarchar(50),
    @AdjType6           nvarchar(50),
    @AdjType7           nvarchar(50),
    @AdjType8           nvarchar(50),
    @AdjType9           nvarchar(50),
    @AdjType10          nvarchar(50),
    @AdjType11          nvarchar(50),
    @Amount1            decimal(18,5),
    @Amount2            decimal(18,5),
    @Amount3            decimal(18,5),
    @Amount4            decimal(18,5),
    @Amount5            decimal(18,5),
    @Amount6            decimal(18,5),
    @Amount7            decimal(18,5),
    @Amount8            decimal(18,5),
    @Amount9            decimal(18,5),
    @Amount10           decimal(18,5),
    @Amount11           decimal(18,5),
    @AltAmount1         decimal(18,5),    
    @AltAmount2         decimal(18,5),    
    @AltAmount3         decimal(18,5),    
    @AltAmount4         decimal(18,5),    
    @AltAmount5         decimal(18,5),    
    @AltAmount6         decimal(18,5),    
    @AltAmount7         decimal(18,5),    
    @AltAmount8         decimal(18,5),    
    @AltAmount9         decimal(18,5),    
    @AltAmount10        decimal(18,5),    
    @AltAmount11        decimal(18,5),
    @Loop               int,
    @CurAmount          decimal(18,5),
    @CurAltAmount       decimal(18,5),
    @CurBrkQty          decimal(18,5),
    @CurPriceBasis      nvarchar(50),
    @CurAdjType         nvarchar(50),
    @tmpBasisValue      decimal(18,5),
    @tmpAdjustValue     decimal(18,5),
    @tmpPriceBasis      nvarchar(50),
    @VendorSaleMarkup   decimal(18,5),
    @UsingBaseUOM		bit

  DECLARE @PriceBreaks TABLE (BreakQty DECIMAL(18,5), Price DECIMAL(18,5))
	
  -- Epicor-specific
  DECLARE @BasePrice decimal(18,5)
  DECLARE @SaveDiscount decimal(18,5)  
  DECLARE @QtyPriceMatrixID uniqueidentifier
  DECLARE @CurrQtyPriceList nvarchar(50)
  DECLARE @CurrBasePriceList nvarchar(50)
  DECLARE @CustomerDiscount decimal(18,5)
  DECLARE @Debug as tinyint
  SET @BasePrice = NULL
  SET @SaveDiscount = NULL
  SET @Debug = 1
  
 
  IF @PricingDate IS NULL
  BEGIN
    SET @PricingDate = getdate()
    SET @IsSalePrice = 0
  END    
    
  IF @Debug = 1 
    SELECT @ProductId as ''ProductId'',@CustomerId as ''CustId'',@PricingDate as ''Price Date''


  /* First get the product information */
  IF @ProductID IS null
  BEGIN
    print ''Error - no product selected''
    RETURN 99
  END

  SELECT 
    @ProductCode = ProductCode, 
    @ProductUM = UnitOfMeasure,
    @SalePrice = BasicSalePrice,  
    @ListPrice = BasicListPrice,
    @SaleStartDate = BasicSaleStartDate,
    @SaleEndDate = BasicSaleEndDate
  FROM Product (NOLOCK)
  WHERE Id = @ProductId
    
  IF @SaleStartDate IS NULL 
    SET @SaleStartDate = getdate()
  
  IF IsNull(@UnitOfMeasure,'''') = ''''
    SET @UnitOfMeasure = @ProductUM
    
  SET @UsingBaseUOM = 1
  IF (@UnitOfMeasure <> @ProductUM)
	SET @UsingBaseUOM = 0
    
  SET @Price = NULL

  -- Check if no customer in or they just want list - give it to them
  IF @RegularPrice = 1
  BEGIN
    SET @Price = @ListPrice
	SELECT * FROM @PriceBreaks  -- empty for now
	SELECT @Price AS Price, @IsSalePrice AS IsSalePrice
    RETURN
  END
  
  IF @CustomerId is null
  BEGIN
	SELECT
      @CustomerType = Value,
      @CustomerDiscount = 0,
      @ParentCustomerId = NULL 
      FROM ApplicationSetting WHERE name = ''Default_CustomerType''
    --SET @Price = @ListPrice
    --IF @SalePrice > 0 AND @SalePrice < @ListPrice AND
    --  @SaleStartDate < = @PricingDate AND 
    --  (@SaleEndDate IS NULL OR @SaleEndDate > @PricingDate)
    --  BEGIN
    --    SET @Price = @SalePrice
    --    SET @IsSalePrice = 1
    --  END
    --RETURN
  END

  /* Next get the customer information */
  SELECT
    @CustomerType = CustomerType,
    @CustomerDiscount = DiscountPercent,
    @ParentCustomerId = ParentId
  FROM Customer (NOLOCK)
  WHERE Id = @CustomerId


  /* Now try and find which record will hold the key */
  SET @PriceMatrixId = NULL
  SET @BasePrice = NULL

/* Create temp table entries for price lists - Customer/ShipTo first */
  IF object_id(''tempdb..#PriceLists'') IS NOT NULL
  BEGIN
     DROP TABLE #PriceLists
  END
  CREATE TABLE #PriceLists (
    [Sequence] [int] IDENTITY(1,1) NOT NULL,
    [PriceList] [nvarchar](50) NOT NULL)

  INSERT INTO #PriceLists (PriceList) 
  SELECT PriceBasis01
  FROM PriceMatrix
  WHERE 
    RecordType = ''Customer Price List'' AND
    CustomerKeyPart = @CustomerId AND
    ActivateOn <= @PricingDate AND
    (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
  ORDER BY CAST(ProductKeyPart AS INT)

  /* Parent customer if any */
  IF @ParentCustomerId <> @CustomerId AND @ParentCustomerId is not null
  BEGIN
    INSERT INTO #PriceLists (PriceList) 
    SELECT PriceBasis01
    FROM PriceMatrix
    WHERE 
      RecordType = ''Customer Price List'' AND
      CustomerKeyPart = @ParentCustomerId AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
    ORDER BY CAST(ProductKeyPart as INT)
  END

  /* Customer Group */
  IF ISNULL(@CustomerType,'''') <> ''''
  BEGIN
    INSERT INTO #PriceLists (PriceList) 
    SELECT PriceBasis01
    FROM PriceMatrix
    WHERE 
      RecordType = ''Customer Group Price List'' AND
      CustomerKeyPart = @CustomerType AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
    ORDER BY CAST(ProductKeyPart AS INT)
  END

  IF @Debug = 1 SELECT * FROM #PriceLists -- DEBUG

  /* Now all the price lists are loaded in - need to traverse them to get the qty record */
  DECLARE cPriceList CURSOR FOR SELECT PriceList FROM #PriceLists (NOLOCK)
  DECLARE cPriceList2 CURSOR FOR SELECT PriceList FROM #PriceLists (NOLOCK)
  OPEN cPriceList
  OPEN cPriceList2
  FETCH NEXT FROM cPriceList INTO @CurrQtyPriceList
  
  WHILE (@@FETCH_STATUS = 0 AND @QtyPriceMatrixID IS NULL) 
  BEGIN  
    IF @Debug = 1 SELECT @CurrQtyPriceList as ''Checking Qty List''
    /* For a given price list - now try to find product-specific record */   
    SELECT @PriceMatrixId = Id
    FROM PriceMatrix (NOLOCK)
    WHERE
      RecordType = ''Price List Product'' AND
      CurrencyCode = @CurrencyCode AND
      Warehouse = @Warehouse AND
      UnitOfMeasure = @UnitOfMeasure AND
      CustomerKeyPart = @CurrQtyPriceList AND
      ProductKeyPart =  CAST(@ProductId AS NVARCHAR(50)) AND
      ActivateOn <= @PricingDate AND
      (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
      
    IF @Debug = 1 AND @PriceMatrixID IS NOT NULL SELECT @PriceMatrixId as ''Price List Product MtxID''
    
    IF @PriceMatrixId IS NOT NULL AND @QtyPriceMatrixID IS NULL SET
      @QtyPriceMatrixID = @PriceMatrixID

    IF @PriceMatrixId is NULL 
    BEGIN
      -- Find product group
      SELECT TOP 1 @PriceMatrixId = Id
      FROM PriceMatrix (NOLOCK)
      WHERE
        RecordType = ''Price List Product Group'' AND
        CurrencyCode = @CurrencyCode AND
        Warehouse = @Warehouse AND
        (UnitOfMeasure = @UnitOfMeasure OR
         UnitOfMeasure = '''') AND
        CustomerKeyPart = @CurrQtyPriceList AND
        ProductKeyPart =  @ProductCode AND
        ActivateOn <= @PricingDate AND
        (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
      IF @Debug = 1 AND @PriceMatrixId IS NOT NULL SELECT @PriceMatrixId as ''Price List Product Group MtxID'',@ProductCode as ''Prod Code''
    END
    
    IF @PriceMatrixId IS NOT NULL AND @QtyPriceMatrixID IS NULL SET
      @QtyPriceMatrixID = @PriceMatrixID
    
		IF @Debug = 1 select @PriceMatrixId as ''CurrentMatxId'',@BasePrice as ''BasePrice'',@QtyPriceMatrixID as ''QtyPriceMatxId''

    /* Got a qty matrix record - start to process it */
    IF @PriceMatrixId IS NOT NULL
    BEGIN
      SELECT
        @BrkQty1 = BreakQty01,
        @BrkQty2 = BreakQty02,
        @BrkQty3 = BreakQty03,
        @BrkQty4 = BreakQty04,
        @BrkQty5 = BreakQty05,
        @BrkQty6 = BreakQty06,
        @BrkQty7= BreakQty07,
        @BrkQty8 = BreakQty08,
        @BrkQty9 = BreakQty09,
        @BrkQty10 = BreakQty10,
        @BrkQty11 = BreakQty11,
        @AdjType1 = AdjustmentType01,
        @AdjType2 = AdjustmentType02,
        @AdjType3 = AdjustmentType03,
        @AdjType4 = AdjustmentType04,
        @AdjType5 = AdjustmentType05,
        @AdjType6 = AdjustmentType06,
        @AdjType7 = AdjustmentType07,
        @AdjType8 = AdjustmentType08,
        @AdjType9 = AdjustmentType09,
        @AdjType10 = AdjustmentType10,
        @AdjType11 = AdjustmentType11,
        @Amount1 = Amount01,
        @Amount2 = Amount02,
        @Amount3 = Amount03,
        @Amount4 = Amount04,
        @Amount5 = Amount05,
        @Amount6 = Amount06,
        @Amount7 = Amount07,
        @Amount8 = Amount08,
        @Amount9 = Amount09,
        @Amount10 = Amount10,
        @Amount11 = Amount11,
        @BasePrice = ISNULL(AltAmount01,0)
      FROM PriceMatrix (NOLOCK) 
      WHERE Id = @PriceMatrixId
      
      -- Save Discount % in case - this is for price - the discount is being saved in @PriceBreaks
      -- but we are assuming that if the first entry is % off then all are (Epicor is this way)
      
      	IF @AdjType1 = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @Amount1
      	IF @AdjType1 = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @Amount1
      	IF @AdjType1 = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @Amount1
      	IF @AdjType1 = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @Amount1
      	IF @AdjType1 = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @Amount1
      	IF @AdjType1 = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @Amount1
      	IF @AdjType1 = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @Amount1
      	IF @AdjType1 = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @Amount1
      	IF @AdjType1 = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @Amount1
      	IF @AdjType1 = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @Amount1
      	IF @AdjType1 = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @Amount1

      
  																								
		-- Capture Price Breaks
		DELETE FROM @PriceBreaks
		INSERT INTO @PriceBreaks SELECT 1, @BasePrice
		IF @BrkQty1 > 0 AND @Amount1 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty1, @Amount1
		IF @BrkQty2 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty2, @Amount2
		IF @BrkQty3 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty3, @Amount3
		IF @BrkQty4 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty4, @Amount4
		IF @BrkQty5 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty5, @Amount5
		IF @BrkQty6 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty6, @Amount6
		IF @BrkQty7 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty7, @Amount7
		IF @BrkQty8 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty8, @Amount8
		IF @BrkQty9 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty9, @Amount9
		IF @BrkQty10 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty10, @Amount10
		IF @BrkQty11 > 0 INSERT INTO @PriceBreaks SELECT @BrkQty11, @Amount11
		
			IF @QtyOrdered >= @BrkQty1 AND @BrkQty1 > 0
			SELECT
				@CurAmount = @Amount1,
				@CurBrkQty = @BrkQty1,    
				@CurAdjType = @AdjType1			

			IF @QtyOrdered >= @BrkQty2 AND @BrkQty2 > 0
			SELECT
				@CurAmount = @Amount2,
				@CurBrkQty = @BrkQty2,
				@CurAdjType = @AdjType2

			IF @QtyOrdered >= @BrkQty3 AND @BrkQty3 > 0
			SELECT
				@CurAmount = @Amount3,
				@CurBrkQty = @BrkQty3,
				@CurAdjType = @AdjType3

			IF @QtyOrdered >= @BrkQty4 AND @BrkQty4 > 0
			SELECT
				@CurAmount = @Amount4,
				@CurBrkQty = @BrkQty4,
				@CurAdjType = @AdjType4

			IF @QtyOrdered >= @BrkQty5 AND @BrkQty5 > 0
			SELECT
				@CurAmount = @Amount5,
				@CurBrkQty = @BrkQty5,
				@CurAdjType = @AdjType5

			IF @QtyOrdered >= @BrkQty6 AND @BrkQty6 > 0
			SELECT
				@CurAmount = @Amount6,
				@CurBrkQty = @BrkQty6,        
				@CurAdjType = @AdjType6

			IF @QtyOrdered >= @BrkQty7 AND @BrkQty7 > 0
			SELECT
				@CurAmount = @Amount7,
				@CurBrkQty = @BrkQty7,        
				@CurAdjType = @AdjType7

			IF @QtyOrdered >= @BrkQty8 AND @BrkQty8 > 0
			SELECT
				@CurAmount = @Amount8,
				@CurBrkQty = @BrkQty8,      
				@CurAdjType = @AdjType8

			IF @QtyOrdered >= @BrkQty9 AND @BrkQty9 > 0
			SELECT
				@CurAmount = @Amount9,
				@CurBrkQty = @BrkQty9,        
				@CurAdjType = @AdjType9

			IF @QtyOrdered >= @BrkQty10 AND @BrkQty10 > 0
			SELECT
				@CurAmount = @Amount10,
				@CurBrkQty = @BrkQty10,        
				@CurAdjType = @AdjType10

			IF @QtyOrdered >= @BrkQty11 AND @BrkQty11 > 0
			SELECT
				@CurAmount = @Amount11,
				@CurBrkQty = @BrkQty11,        
				@CurAdjType = @AdjType11
				
		    IF @CurAdjType = ''P'' AND @BasePrice = 0 SET @SaveDiscount = @CurAmount
			
			IF @Debug = 1 SELECT @PriceMatrixId as ''Selected MtxID'',@CurAmount as ''CurrAmt'',@CurBrkQty as ''CurBrkQty'',
				@CurAdjType as ''AdjType'',@BasePrice as ''BasePrice''
			
				-- Next we have to get base price - secondary traversal
			IF @BasePrice = 0
			BEGIN			  
				FETCH NEXT FROM cPriceList2 INTO @CurrBasePriceList
				
			
				WHILE (@@FETCH_STATUS = 0 AND @BasePrice = 0)
				BEGIN
				  IF @Debug = 1 SELECT @CurrBasePriceList as ''Base price list''
					SELECT @BasePrice = ISNULL(AltAmount01,0)
					FROM PriceMatrix (NOLOCK)
					WHERE
	  				RecordType = ''Price List Product'' AND
						CurrencyCode = @CurrencyCode AND
						Warehouse = @Warehouse AND
						UnitOfMeasure = @UnitOfMeasure AND
						CustomerKeyPart = @CurrBasePriceList AND
						ProductKeyPart =  CAST(@ProductId AS NVARCHAR(50)) AND
						ActivateOn <= @PricingDate AND
						(DeactivateOn IS NULL OR DeactivateOn > @PricingDate)						
					
			
					IF @BasePrice = 0 
					BEGIN
						SELECT @BasePrice = ISNULL(AltAmount01,0)
	 					FROM PriceMatrix (NOLOCK)
						WHERE
  						RecordType = ''Price List Product Group'' AND
							CurrencyCode = @CurrencyCode AND
							Warehouse = @Warehouse AND
							 (UnitOfMeasure = @UnitOfMeasure OR
								UnitOfMeasure = '''') AND
							CustomerKeyPart = @CurrBasePriceList AND
							ProductKeyPart =  @ProductCode AND
							ActivateOn <= @PricingDate AND
							(DeactivateOn IS NULL OR DeactivateOn > @PricingDate)
					END		 
					
					FETCH NEXT FROM cPriceList2 INTO @CurrBasePriceList		
				END  -- current base price list
											
				
			END -- capture of base price/cPriceList2						
		END  -- if price matrixid is not null
		FETCH NEXT FROM cPriceList INTO @CurrQtyPriceList
	END  -- capture of qty matrix/cPriceList

	if @DEbug = 1 select @CurAmount as ''curamount'',@SaveDiscount as ''SavedDisct%'',
		@BasePrice as ''Base Price'',@CurBrkQty as ''cur brk qty'', @CurAdjType as ''CurAdjType'',
		@CustomerDiscount as ''Customer Disct %'',@ListPrice as ''List Price''

	/* Do the actual math next */
	IF ISNULL(@BasePrice,0) > 0
		SET @Price = @BasePrice -- initial

    BEGIN    
		IF @CurAdjType IN (''A'', ''P'')  
			SET @Price = @CurAmount
	END
	
	-- Final check - discount basis but no base price - have to use ListPrice
	IF ISNULL(@BasePrice,0) = 0 AND ISNULL(@ListPrice,0) > 0
	BEGIN
	  IF @Debug = 1 SELECT ''BasePrice from Product - save disct = '',@SaveDiscount
	  IF @SaveDiscount > 0
	  BEGIN
		SET @Price = @ListPrice * (1 - (@SaveDiscount / 100))
		UPDATE @PriceBreaks SET Price = @ListPrice * (1 - Price / 100)
		  WHERE Price > 0
	  END
	  ELSE
		SET @Price = @ListPrice
	END
 
	-- Close up
  CLOSE cPriceList
  CLOSE cPriceList2
  DEALLOCATE cPriceList
  DEALLOCATE cPriceList2
  DROP TABLE #PriceLists
  
  -- Final check - discount but no base price (get from List Price)
  IF ISNULL(@BasePrice,0) = 0 AND ISNULL(@ListPrice,0) > 0
  BEGIN
    IF @Debug = 1 SELECT ''part master base - save disct = '',@SaveDiscount
    IF @SaveDiscount > 0 
       SET @Price = @ListPrice * (1 - (@SaveDiscount / 100))
    ELSE
        SET @Price = @ListPrice        
  END

  IF @Price is null AND @UsingBaseUOM = 1
    SET @Price = @ListPrice
    
  IF @Price is null AND @UsingBaseUOM = 0
	SET @Price = 0
    
  -- Apply customer discount next
  SET @Price = @Price * (1 - @CustomerDiscount / 100)
  
  IF @SalePrice > 0 AND @SalePrice < @Price AND
    @SaleStartDate <= @PricingDate AND (@SaleEndDate IS NULL OR @SaleEndDate >= @PricingDate)
    BEGIN
      SELECT
        @Price = @SalePrice, -- ifit''s actually less, set it
        @IsSalePrice = 1
    END
    
    IF @Debug = 1 select @Price as ''Returned price'',@IsSalePrice as ''IsSalePrice''

	-- this output format is required to work with the ISC 3.4 PricingService_Default
	
	SELECT * FROM @PriceBreaks  -- empty for now
	SELECT @Price AS Price, @IsSalePrice AS IsSalePrice

END -- End of procedure
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[WebPage_After_Delete] on [dbo].[WebPage]'
GO
IF OBJECT_ID(N'[dbo].[WebPage_After_Delete]', 'TR') IS NULL
EXEC sp_executesql N'CREATE TRIGGER [dbo].[WebPage_After_Delete]
   ON  [dbo].[WebPage]
   AFTER DELETE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
    DELETE cm FROM ContentManager cm INNER JOIN DELETED d ON d.ContentManagerId = cm.Id

END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PaymentMethod]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[PaymentMethod]', N'ActivateOn') IS NULL
ALTER TABLE [dbo].[PaymentMethod] ADD[ActivateOn] [datetime2] NOT NULL CONSTRAINT [DF_PaymentMethod_Active] DEFAULT (getdate())
IF COL_LENGTH(N'[dbo].[PaymentMethod]', N'DeactivateOn') IS NULL
ALTER TABLE [dbo].[PaymentMethod] ADD[DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[PaymentMethod]', N'Active') IS NOT NULL
ALTER TABLE [dbo].[PaymentMethod] DROP COLUMN [Active]
IF COL_LENGTH(N'[dbo].[PaymentMethod]', N'Deactivate') IS NOT NULL
ALTER TABLE [dbo].[PaymentMethod] DROP COLUMN [Deactivate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PaymentMethod]', N'PaymentTermId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PaymentMethod]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PaymentMethod].[PaymentTermId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PaymentMethod]', N'TermsCode') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PaymentMethod]', N'Name') IS NULL)
EXEC sp_rename N'[dbo].[PaymentMethod].[TermsCode]', N'Name', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PaymentMethod] ALTER COLUMN [IsCreditCard] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PaymentMethod] on [dbo].[PaymentMethod]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PaymentMethod' AND object_id = OBJECT_ID(N'[dbo].[PaymentMethod]'))
ALTER TABLE [dbo].[PaymentMethod] ADD CONSTRAINT [PK_PaymentMethod] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_PaymentMethod_NaturalKey] on [dbo].[PaymentMethod]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PaymentMethod_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[PaymentMethod]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_PaymentMethod_NaturalKey] ON [dbo].[PaymentMethod] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[EmailTemplate_After_Delete] on [dbo].[EmailTemplate]'
GO
IF OBJECT_ID(N'[dbo].[EmailTemplate_After_Delete]', 'TR') IS NULL
EXEC sp_executesql N'-- =============================================
-- Author:		Darwin Zins
-- Create date: 4/7/2014
-- Description:	Delete contained ContentManager
-- =============================================
CREATE TRIGGER [dbo].[EmailTemplate_After_Delete]
   ON  [dbo].[EmailTemplate] 
   AFTER DELETE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    DELETE cm FROM ContentManager cm INNER JOIN DELETED d ON d.ContentManagerId = cm.Id

END'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Category]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Category]', N'UrlSegment') IS NULL
ALTER TABLE [dbo].[Category] ADD[UrlSegment] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_Category_UrlSegment] DEFAULT ('')
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Category]', N'Description') IS NOT NULL
ALTER TABLE [dbo].[Category] DROP COLUMN [Description]
IF COL_LENGTH(N'[dbo].[Category]', N'StyleSheet') IS NOT NULL
ALTER TABLE [dbo].[Category] DROP COLUMN [StyleSheet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Category]', N'CategoryId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Category]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Category].[CategoryId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Category]', N'Active') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Category]', N'ActivateOn') IS NULL)
EXEC sp_rename N'[dbo].[Category].[Active]', N'ActivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Category]', N'Deactivate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Category]', N'DeactivateOn') IS NULL)
EXEC sp_rename N'[dbo].[Category].[Deactivate]', N'DeactivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Category]', N'MetaTags') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Category]', N'MetaKeywords') IS NULL)
EXEC sp_rename N'[dbo].[Category].[MetaTags]', N'MetaKeywords', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Category]', N'AltText') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Category]', N'ImageAltText') IS NULL)
EXEC sp_rename N'[dbo].[Category].[AltText]', N'ImageAltText', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Category] ALTER COLUMN [SmallImagePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Category] ALTER COLUMN [LargeImagePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Category] ALTER COLUMN [ActivateOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Category] ALTER COLUMN [DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Category] ALTER COLUMN [PageTitle] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Category] ALTER COLUMN [IsFeatured] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Category] ALTER COLUMN [IsDynamic] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Category] ALTER COLUMN [ImageAltText] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Category] on [dbo].[Category]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Category' AND object_id = OBJECT_ID(N'[dbo].[Category]'))
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [PK_Category] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Category_Name] on [dbo].[Category]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Category_Name' AND object_id = OBJECT_ID(N'[dbo].[Category]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Category_Name] ON [dbo].[Category] ([Name], [WebSiteId], [ParentId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Category_NaturalKey] on [dbo].[Category]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Category_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Category]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Category_NaturalKey] ON [dbo].[Category] ([WebSiteId], [ParentId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[Dealer_After_Delete] on [dbo].[Dealer]'
GO
IF OBJECT_ID(N'[dbo].[Dealer_After_Delete]', 'TR') IS NULL
EXEC sp_executesql N'-- =============================================
-- Author:		Darwin Zins
-- Create date: 5/2/2014
-- Description:	Delete contained ContentManager
-- =============================================
CREATE TRIGGER [dbo].[Dealer_After_Delete]
   ON  [dbo].[Dealer]
   AFTER DELETE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
    DELETE cm FROM ContentManager cm INNER JOIN DELETED d ON d.ContentManagerId = cm.Id

END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[RuleManager]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[RuleManager]', N'RuleManagerId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[RuleManager]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[RuleManager].[RuleManagerId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_RulesManager] on [dbo].[RuleManager]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_RulesManager' AND object_id = OBJECT_ID(N'[dbo].[RuleManager]'))
ALTER TABLE [dbo].[RuleManager] ADD CONSTRAINT [PK_RulesManager] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[Category_After_Delete] on [dbo].[Category]'
GO
IF OBJECT_ID(N'[dbo].[Category_After_Delete]', 'TR') IS NULL
EXEC sp_executesql N'-- =============================================
-- Author:		Darwin Zins
-- Create date: 1/4/2011
-- Description:	If there are any child Categories, set their ParentId to Null
-- =============================================
CREATE TRIGGER [dbo].[Category_After_Delete]
   ON  [dbo].[Category] 
   AFTER DELETE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
    UPDATE Category SET ParentId = NULL WHERE ParentId IN (SELECT Id FROM DELETED)	
	DELETE rm FROM RuleManager rm INNER JOIN DELETED d ON d.RuleManagerId = rm.Id
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[GetListPrice_Epicor]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetListPrice_Epicor]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
EXEC sp_executesql N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
CREATE FUNCTION [dbo].[GetListPrice_Epicor]
(
	@ProductId uniqueidentifier,
	@CurrencyCode nvarchar(50),
	@Warehouse	nvarchar(50),
	@UnitOfMeasure nvarchar(50),
	@PricingDate datetime
)

RETURNS Decimal(18,5)
AS
BEGIN
	declare @ListPrice decimal(18,5)

	SELECT @ListPrice = Amount01
	FROM PriceMatrix (NOLOCK)
	WHERE
		RecordType = ''Product'' AND
		CurrencyCode = @CurrencyCode AND
		Warehouse = @Warehouse AND
		UnitOfMeasure = @UnitOfMeasure AND
		CustomerKeyPart = '''' AND
		ProductKeyPart = @ProductId AND
		dateadd(dd,0,datediff(dd,0,DeactivateOn)) <= @PricingDate and 
		(DeactivateOn IS NULL OR DeactivateOn > @PricingDate)

	-- Return the result of the function
	RETURN @ListPrice

END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[GetPriceMatrixId_Epicor]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetPriceMatrixId_Epicor]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
EXEC sp_executesql N'-- =============================================
-- Author:		Bill Behning
-- Create date: 12-2-2010
-- Description:	Returns the proper price matrix record 
-- =============================================
CREATE FUNCTION [dbo].[GetPriceMatrixId_Epicor]
(
	@CustomerId uniqueidentifier,
	@ProductId uniqueidentifier,
	@CurrencyCode nvarchar(50),
	@Warehouse	nvarchar(50),
	@UnitOfMeasure nvarchar(50),
	@PricingDate datetime
)

RETURNS uniqueidentifier
AS
BEGIN
	-- Declare the return variable here
	Declare @PriceMatrixId uniqueidentifier,
		@ParentCustomerId   uniqueidentifier,
		@ProductPriceCode   nvarchar(50),
		@CustomerPriceCode  nvarchar(50)
	
	-- Get Product Info
	SELECT @ProductPriceCode = PriceCode
		FROM Product (NOLOCK)
		WHERE Id = @ProductId

	IF @CustomerId is not null
	BEGIN
		SELECT
			@CustomerPriceCode = customertype,
			@ParentCustomerId = ParentId
		FROM Customer (NOLOCK)
		WHERE Id = @CustomerId
	END

	/* Customer/Product */
	IF @PriceMatrixId IS NULL AND @CustomerId is not null
	BEGIN
		SELECT @PriceMatrixID = ID
		FROM PriceMatrix (NOLOCK) 
		WHERE
			RecordType = ''Customer/Product'' AND
			CurrencyCode = @CurrencyCode AND
			Warehouse = @Warehouse AND
			UnitOfMeasure = @UnitOfMeasure AND
			CustomerKeyPart = @CustomerId AND
			ProductKeyPart = @ProductId AND
			ActivateOn <= @PricingDate AND
			(DeactivateOn IS NULL OR DeactivateOn >= @PricingDate)
	END

	/* Customer/Product Price Code */
	IF @PriceMatrixId IS NULL AND @CustomerId  is not null
	BEGIN
		SELECT @PriceMatrixID = ID
		FROM PriceMatrix (NOLOCK) 
		WHERE
			RecordType = ''Customer/Product Price Code'' AND
			CurrencyCode = @CurrencyCode AND
			Warehouse = @Warehouse AND
			CustomerKeyPart = @CustomerId AND
			ProductKeyPart =  @ProductPriceCode AND
			ActivateOn <= @PricingDate AND
			(DeactivateOn IS NULL OR DeactivateOn >= @PricingDate)

			-- UnitOfMeasure = @UnitOfMeasure AND
	END

	/* Parent Customer/Product */
	IF @PriceMatrixId IS NULL AND @ParentCustomerId  is not null
	BEGIN
		SELECT @PriceMatrixID = ID
		FROM PriceMatrix (NOLOCK) 
		WHERE
			RecordType = ''Customer/Product'' AND
			CurrencyCode = @CurrencyCode AND
			Warehouse = @Warehouse AND
			UnitOfMeasure = @UnitOfMeasure AND
			CustomerKeyPart = @ParentCustomerId AND
			ProductKeyPart = @ProductId AND
			ActivateOn <= @PricingDate AND
			(DeactivateOn IS NULL OR DeactivateOn >= @PricingDate)
	END

	/* Parent Customer/Product Price Code */
	IF @PriceMatrixId IS NULL AND @ParentCustomerId is not null
	BEGIN
		SELECT @PriceMatrixID = ID
		FROM PriceMatrix (NOLOCK) 
		WHERE
			RecordType = ''Customer/Product Price Code'' AND
			CurrencyCode = @CurrencyCode AND
			Warehouse = @Warehouse AND
			CustomerKeyPart = @ParentCustomerId AND
			ProductKeyPart =  @ProductPriceCode AND
			ActivateOn <= @PricingDate AND
			(DeactivateOn IS NULL OR DeactivateOn >= @PricingDate)

			--UnitOfMeasure = @UnitOfMeasure AND
	END

	/* Customer Price Code/Product - don''t see this type in SL but no harm in looking for it */
	IF @PriceMatrixId IS NULL AND @CustomerId  is not null AND @CustomerPriceCode <> ''''
	BEGIN
		SELECT @PriceMatrixID = ID
		FROM PriceMatrix (NOLOCK) 
		WHERE
			RecordType = ''Customer Price Code/Product'' AND
			CurrencyCode = @CurrencyCode AND
			Warehouse = @Warehouse AND
			UnitOfMeasure = @UnitOfMeasure AND
			CustomerKeyPart = @CustomerPriceCode AND
			ProductKeyPart = @ProductId AND
			ActivateOn <= @PricingDate AND
			(DeactivateOn IS NULL OR DeactivateOn >= @PricingDate)
	END        

	/* Customer Price Code/Product Price Code */
	IF @PriceMatrixId IS NULL AND @CustomerId  is not null 
			AND @CustomerPriceCode <> ''''
			AND @ProductPriceCode <> ''''
	BEGIN
		SELECT @PriceMatrixID = ID
		FROM PriceMatrix (NOLOCK) 
		WHERE
			RecordType = ''Customer Price Code/Product Price Code'' AND
			CurrencyCode = @CurrencyCode AND
			Warehouse = @Warehouse AND
			CustomerKeyPart = @CustomerPriceCode AND
			ProductKeyPart = @ProductPriceCode AND
			ActivateOn <= @PricingDate AND
			(DeactivateOn IS NULL OR DeactivateOn >= @PricingDate)

			-- UnitOfMeasure = @UnitOfMeasure AND
	END       

	/* Product Base Record - grabbing this record if nothing else grabbed */
	IF @PriceMatrixId IS NULL
	BEGIN
		SELECT @PriceMatrixID = ID
		FROM PriceMatrix (NOLOCK) 
		WHERE
			RecordType = ''Product'' AND
			CurrencyCode = @CurrencyCode AND
			Warehouse = @Warehouse AND
			UnitOfMeasure = @UnitOfMeasure AND
			CustomerKeyPart IS NULL AND
			ProductKeyPart = @ProductId AND
			ActivateOn <= @PricingDate AND
			(DeactivateOn IS NULL OR DeactivateOn >= @PricingDate)
	END    

	RETURN @PriceMatrixId

END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Persona]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Persona]', N'PersonaId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Persona]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Persona].[PersonaId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Persona]', N'Active') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Persona]', N'ActivateOn') IS NULL)
EXEC sp_rename N'[dbo].[Persona].[Active]', N'ActivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Persona]', N'Deactivate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Persona]', N'DeactivateOn') IS NULL)
EXEC sp_rename N'[dbo].[Persona].[Deactivate]', N'DeactivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Persona] ALTER COLUMN [Description] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Persona] ALTER COLUMN [ActivateOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Persona] ALTER COLUMN [DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Persona] ALTER COLUMN [IsDefault] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Persona] on [dbo].[Persona]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Persona' AND object_id = OBJECT_ID(N'[dbo].[Persona]'))
ALTER TABLE [dbo].[Persona] ADD CONSTRAINT [PK_Persona] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Persona_NaturalKey] on [dbo].[Persona]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Persona_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Persona]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Persona_NaturalKey] ON [dbo].[Persona] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[GetVendorSalePrice_Epicor]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GetVendorSalePrice_Epicor]') AND (type = 'IF' OR type = 'FN' OR type = 'TF'))
EXEC sp_executesql N'-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
CREATE FUNCTION [dbo].[GetVendorSalePrice_Epicor]
(
	@QtyOrdered int,
	@ProductId uniqueidentifier,
	@CurrencyCode nvarchar(50),
	@Warehouse	nvarchar(50),
	@UnitOfMeasure nvarchar(50),
	@PricingDate datetime
)

RETURNS Decimal(18,5)
AS
BEGIN
	declare @SalePrice decimal(18,5),
		@PriceMatrixId uniqueidentifier,
        @BrkQty1 int,
        @BrkQty2 int,
        @BrkQty3 int,
        @BrkQty4 int,
        @BrkQty5 int,
        @BrkQty6 int,
        @BrkQty7 int,
        @BrkQty8 int,
        @BrkQty9 int,
        @BrkQty10 int,
        @BrkQty11 int,
        @Amount1 decimal(18,5),
        @Amount2 decimal(18,5),
        @Amount3 decimal(18,5),
        @Amount4 decimal(18,5),
        @Amount5 decimal(18,5),
        @Amount6 decimal(18,5),
        @Amount7 decimal(18,5),
        @Amount8 decimal(18,5),
        @Amount9 decimal(18,5),
        @Amount10 decimal(18,5),
        @Amount11 decimal(18,5)


      SET @PriceMatrixId = NULL
      SET @SalePrice = 0
      SELECT 
        @PriceMatrixId = Id,
        @BrkQty1 = BreakQty01,
        @BrkQty2 = BreakQty02,
        @BrkQty3 = BreakQty03,
        @BrkQty4 = BreakQty04,
        @BrkQty5 = BreakQty05,
        @BrkQty6 = BreakQty06,
        @BrkQty7 = BreakQty07,
        @BrkQty8 = BreakQty08,
        @BrkQty9 = BreakQty09,
        @BrkQty10 = BreakQty10,
        @BrkQty11 = BreakQty11,
        @Amount1 = Amount01,
        @Amount2 = Amount02,
        @Amount3 = Amount03,
        @Amount4 = Amount04,
        @Amount5 = Amount05,
        @Amount6 = Amount06,
        @Amount7 = Amount07,
        @Amount8 = Amount08,
        @Amount9 = Amount09,
        @Amount10 = Amount10,
        @Amount11 = Amount11
      FROM PriceMatrix (NOLOCK) 
      WHERE
        RecordType = ''Product Sale'' AND
        CurrencyCode = @CurrencyCode AND
        Warehouse = @Warehouse AND
        UnitOfMeasure = @UnitOfMeasure AND
        CustomerKeyPart = '''' AND
        ProductKeyPart = @ProductId AND
        ActivateOn <= @PricingDate AND
        (DeactivateOn IS NULL OR DeactivateOn > @PricingDate)

      IF @PriceMatrixId IS NOT NULL
      BEGIN
        IF @QtyOrdered >= @BrkQty1                    SET @SalePrice = @Amount1
        IF @QtyOrdered >= @BrkQty2  AND @BrkQty2  > 0 SET @SalePrice = @Amount2
        IF @QtyOrdered >= @BrkQty3  AND @BrkQty3  > 0 SET @SalePrice = @Amount3
        IF @QtyOrdered >= @BrkQty4  AND @BrkQty4  > 0 SET @SalePrice = @Amount4
        IF @QtyOrdered >= @BrkQty5  AND @BrkQty5  > 0 SET @SalePrice = @Amount5
        IF @QtyOrdered >= @BrkQty6  AND @BrkQty6  > 0 SET @SalePrice = @Amount6
        IF @QtyOrdered >= @BrkQty7  AND @BrkQty7  > 0 SET @SalePrice = @Amount7
        IF @QtyOrdered >= @BrkQty8  AND @BrkQty8  > 0 SET @SalePrice = @Amount8
        IF @QtyOrdered >= @BrkQty9  AND @BrkQty9  > 0 SET @SalePrice = @Amount9
        IF @QtyOrdered >= @BrkQty10 AND @BrkQty10 > 0 SET @SalePrice = @Amount10
        IF @QtyOrdered >= @BrkQty11 AND @BrkQty11 > 0 SET @SalePrice = @Amount11    
      END

	-- Return the result of the function
	RETURN @SalePrice

END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[State]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[State]', N'StateId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[State]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[State].[StateId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[State] ALTER COLUMN [Taxable] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[State] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[State] ALTER COLUMN [TaxFreight] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_State] on [dbo].[State]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_State' AND object_id = OBJECT_ID(N'[dbo].[State]'))
ALTER TABLE [dbo].[State] ADD CONSTRAINT [PK_State] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_State_NaturalKey] on [dbo].[State]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_State_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[State]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_State_NaturalKey] ON [dbo].[State] ([CountryId], [Abbreviation])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[LocalTaxRate]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[LocalTaxRate]', N'LocalTaxRateId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[LocalTaxRate]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[LocalTaxRate].[LocalTaxRateId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[LocalTaxRate]', N'Zip') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[LocalTaxRate]', N'PostalCode') IS NULL)
EXEC sp_rename N'[dbo].[LocalTaxRate].[Zip]', N'PostalCode', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[LocalTaxRate] ALTER COLUMN [TaxFreight] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_LocalTaxRate] on [dbo].[LocalTaxRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_LocalTaxRate' AND object_id = OBJECT_ID(N'[dbo].[LocalTaxRate]'))
ALTER TABLE [dbo].[LocalTaxRate] ADD CONSTRAINT [PK_LocalTaxRate] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_LocalTaxRate_NaturalKey] on [dbo].[LocalTaxRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_LocalTaxRate_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[LocalTaxRate]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_LocalTaxRate_NaturalKey] ON [dbo].[LocalTaxRate] ([PostalCode])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Carrier]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Carrier]', N'CarrierId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Carrier]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Carrier].[CarrierId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Carrier]', N'Image') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Carrier]', N'ImagePath') IS NULL)
EXEC sp_rename N'[dbo].[Carrier].[Image]', N'ImagePath', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Carrier] ALTER COLUMN [Description] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Carrier] ALTER COLUMN [ImagePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Carrier] ALTER COLUMN [AccessKey] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Carrier] ALTER COLUMN [Enable] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Carrier] ALTER COLUMN [IsLive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Carrier] ALTER COLUMN [LiveUrl] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Carrier] ALTER COLUMN [TestUrl] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Carrier] ALTER COLUMN [IsPrimaryCarrier] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Carrier] on [dbo].[Carrier]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Carrier' AND object_id = OBJECT_ID(N'[dbo].[Carrier]'))
ALTER TABLE [dbo].[Carrier] ADD CONSTRAINT [PK_Carrier] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Carrier_NaturalKey] on [dbo].[Carrier]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Carrier_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Carrier]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Carrier_NaturalKey] ON [dbo].[Carrier] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[RuleTypeOption]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[RuleTypeOption]', N'RuleTypeOptionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[RuleTypeOption]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[RuleTypeOption].[RuleTypeOptionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_RuleTypeOption] on [dbo].[RuleTypeOption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_RuleTypeOption' AND object_id = OBJECT_ID(N'[dbo].[RuleTypeOption]'))
ALTER TABLE [dbo].[RuleTypeOption] ADD CONSTRAINT [PK_RuleTypeOption] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_RuleTypeOption_NaturalKey] on [dbo].[RuleTypeOption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_RuleTypeOption_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[RuleTypeOption]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_RuleTypeOption_NaturalKey] ON [dbo].[RuleTypeOption] ([RuleTypeId], [CriteriaType], [CriteriaObject])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[StyleClass]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[StyleClass]', N'StyleClassId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[StyleClass]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[StyleClass].[StyleClassId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[StyleClass] ALTER COLUMN [Description] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[StyleClass] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_StyleClass] on [dbo].[StyleClass]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_StyleClass' AND object_id = OBJECT_ID(N'[dbo].[StyleClass]'))
ALTER TABLE [dbo].[StyleClass] ADD CONSTRAINT [PK_StyleClass] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_StyleClass_NaturalKey] on [dbo].[StyleClass]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_StyleClass_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[StyleClass]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_StyleClass_NaturalKey] ON [dbo].[StyleClass] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[IntegrationJobLog]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[IntegrationJobLog]', N'IntegrationJobLogId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[IntegrationJobLog]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[IntegrationJobLog].[IntegrationJobLogId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[IntegrationJobLog] ALTER COLUMN [LogDateTime] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_IntegrationJobLog] on [dbo].[IntegrationJobLog]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_IntegrationJobLog' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJobLog]'))
ALTER TABLE [dbo].[IntegrationJobLog] ADD CONSTRAINT [PK_IntegrationJobLog] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_IntegrationJob] on [dbo].[IntegrationJobLog]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJob' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJobLog]'))
CREATE NONCLUSTERED INDEX [IX_IntegrationJob] ON [dbo].[IntegrationJobLog] ([IntegrationJobId], [Sequence] DESC)
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[IntegrationJobLog_InsteadOf_Insert] on [dbo].[IntegrationJobLog]'
GO
IF OBJECT_ID(N'[dbo].[IntegrationJobLog_InsteadOf_Insert]', 'TR') IS NULL
EXEC sp_executesql N'CREATE TRIGGER [dbo].[IntegrationJobLog_InsteadOf_Insert]
	ON  [dbo].[IntegrationJobLog]
	INSTEAD OF INSERT
AS 
BEGIN
	SET NOCOUNT ON;

	INSERT INTO IntegrationJobLog (IntegrationJobId, Sequence, TypeName, LogDateTime, Message) SELECT IntegrationJobId, Sequence, TypeName, LogDateTime, left(Message, 5000) FROM INSERTED
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Company]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Company]', N'LeftNavigation') IS NOT NULL
ALTER TABLE [dbo].[Company] DROP COLUMN [LeftNavigation]
IF COL_LENGTH(N'[dbo].[Company]', N'BottomNavigation') IS NOT NULL
ALTER TABLE [dbo].[Company] DROP COLUMN [BottomNavigation]
IF COL_LENGTH(N'[dbo].[Company]', N'RightNavigation') IS NOT NULL
ALTER TABLE [dbo].[Company] DROP COLUMN [RightNavigation]
IF COL_LENGTH(N'[dbo].[Company]', N'TopNavigation') IS NOT NULL
ALTER TABLE [dbo].[Company] DROP COLUMN [TopNavigation]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Company]', N'CompanyId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Company]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Company].[CompanyId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Company]', N'Zip') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Company]', N'PostalCode') IS NULL)
EXEC sp_rename N'[dbo].[Company].[Zip]', N'PostalCode', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Company]', N'Image') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Company]', N'LogoImagePath') IS NULL)
EXEC sp_rename N'[dbo].[Company].[Image]', N'LogoImagePath', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Company] ALTER COLUMN [LogoImagePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Company] ALTER COLUMN [ReplaceLogoImage] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Company] on [dbo].[Company]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Company' AND object_id = OBJECT_ID(N'[dbo].[Company]'))
ALTER TABLE [dbo].[Company] ADD CONSTRAINT [PK_Company] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Company_NaturalKey] on [dbo].[Company]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Company_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Company]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Company_NaturalKey] ON [dbo].[Company] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Content]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Content]', N'LanguageId') IS NULL
ALTER TABLE [dbo].[Content] ADD[LanguageId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Content]', N'ContentId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Content]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Content].[ContentId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Content]', N'SubmittedForApproval') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Content]', N'SubmittedForApprovalOn') IS NULL)
EXEC sp_rename N'[dbo].[Content].[SubmittedForApproval]', N'SubmittedForApprovalOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Content]', N'Approved') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Content]', N'ApprovedOn') IS NULL)
EXEC sp_rename N'[dbo].[Content].[Approved]', N'ApprovedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Content]', N'PublishToProduction') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Content]', N'PublishToProductionOn') IS NULL)
EXEC sp_rename N'[dbo].[Content].[PublishToProduction]', N'PublishToProductionOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Content]', N'Created') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Content]', N'CreatedOn') IS NULL)
EXEC sp_rename N'[dbo].[Content].[Created]', N'CreatedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Content] ALTER COLUMN [SubmittedForApprovalOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Content] ALTER COLUMN [ApprovedOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Content] ALTER COLUMN [PublishToProductionOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Content] ALTER COLUMN [CreatedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Content] on [dbo].[Content]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Content' AND object_id = OBJECT_ID(N'[dbo].[Content]'))
ALTER TABLE [dbo].[Content] ADD CONSTRAINT [PK_Content] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Content_ContentManagerId] on [dbo].[Content]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Content_ContentManagerId' AND object_id = OBJECT_ID(N'[dbo].[Content]'))
CREATE NONCLUSTERED INDEX [IX_Content_ContentManagerId] ON [dbo].[Content] ([ContentManagerId]) INCLUDE ([Html])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[Content_After_Update] on [dbo].[Content]'
GO
IF OBJECT_ID(N'[dbo].[Content_After_Update]', 'TR') IS NULL
EXEC sp_executesql N'-- =============================================
-- Author:		Peter Gaard
-- Create date: 8/25/2014
-- Description:	Content Change Trigger
-- =============================================
CREATE TRIGGER [dbo].[Content_After_Update] 
   ON  [dbo].[Content]
   AFTER INSERT,UPDATE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
	UPDATE p SET p.IndexStatus = 1 FROM Product p 
		JOIN Content c ON c.ContentManagerId = p.ContentManagerId
		JOIN INSERTED i ON i.Id = c.Id
		WHERE p.IndexStatus = 0	
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[IntegrationJob]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[IntegrationJob]', N'CreatedOn') IS NOT NULL
ALTER TABLE [dbo].[IntegrationJob] DROP COLUMN [CreatedOn]
IF COL_LENGTH(N'[dbo].[IntegrationJob]', N'CreatedBy') IS NOT NULL
ALTER TABLE [dbo].[IntegrationJob] DROP COLUMN [CreatedBy]
IF COL_LENGTH(N'[dbo].[IntegrationJob]', N'ModifiedOn') IS NOT NULL
ALTER TABLE [dbo].[IntegrationJob] DROP COLUMN [ModifiedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[IntegrationJob]', N'IntegrationJobId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[IntegrationJob]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[IntegrationJob].[IntegrationJobId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[IntegrationJob]', N'IntegrationJobDefinitionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[IntegrationJob]', N'JobDefinitionId') IS NULL)
EXEC sp_rename N'[dbo].[IntegrationJob].[IntegrationJobDefinitionId]', N'JobDefinitionId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[IntegrationJob] ALTER COLUMN [StartDateTime] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[IntegrationJob] ALTER COLUMN [EndDateTime] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[IntegrationJob] ALTER COLUMN [IsRealTime] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[IntegrationJob] ALTER COLUMN [IsPreview] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[IntegrationJob] ALTER COLUMN [DeltaDataSetProcessed] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[IntegrationJob] ALTER COLUMN [ScheduleDateTime] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[IntegrationJob] ALTER COLUMN [FileProcessed] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_IntegrationJob] on [dbo].[IntegrationJob]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_IntegrationJob' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]'))
ALTER TABLE [dbo].[IntegrationJob] ADD CONSTRAINT [PK_IntegrationJob] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_IntegrationJob_StartDateTime_IsRealTime_ScheduleDateTime] on [dbo].[IntegrationJob]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJob_StartDateTime_IsRealTime_ScheduleDateTime' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]'))
CREATE NONCLUSTERED INDEX [IX_IntegrationJob_StartDateTime_IsRealTime_ScheduleDateTime] ON [dbo].[IntegrationJob] ([StartDateTime], [IsRealTime], [ScheduleDateTime])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_IntegrationJob_JobDefinition] on [dbo].[IntegrationJob]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJob_JobDefinition' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]'))
CREATE NONCLUSTERED INDEX [IX_IntegrationJob_JobDefinition] ON [dbo].[IntegrationJob] ([JobDefinitionId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[EmailMessage]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[EmailMessage]', N'EmailMessageId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[EmailMessage]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[EmailMessage].[EmailMessageId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[EmailMessage] ALTER COLUMN [SentDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_EmailMessage] on [dbo].[EmailMessage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_EmailMessage' AND object_id = OBJECT_ID(N'[dbo].[EmailMessage]'))
ALTER TABLE [dbo].[EmailMessage] ADD CONSTRAINT [PK_EmailMessage] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[NightlyMaintenance]'
GO
IF OBJECT_ID(N'[dbo].[NightlyMaintenance]', 'P') IS NULL
EXEC sp_executesql N'
-- =============================================
-- Author:		Darwin Zins
-- Create date: 2/13/2009
-- Description:	Stored Procedure to do Nightly Maintenance Tasks
-- 05/13/2013, jlindbo	- Added support for integration job log cleanup
-- 05/15/2013, jlindbo	- Change to integration cleanup to remove entire job
-- 10/31/2013, belav	- Add EmailMessage cleanup
-- 03/24/2014, jlindbo	- Added support for AbandonedCart rotation
-- 06/09/2014, pgaard	- Added ELMAH_Error log cleanup
-- 08/18/2014, amerrill	- Rfq order cleanup
-- =============================================
CREATE PROCEDURE [dbo].[NightlyMaintenance]
AS
BEGIN
	DECLARE 
		@RetentionWindow INT,
		@RetentionDate DATETIME,
		@Continue INT
	
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	
	INSERT INTO ApplicationLog (Source, Type, Message) VALUES (''NightlyMaintenance'',''INFO'',''Nightly Maintenance Starting'')
	
	DECLARE @PurgeTable TABLE (Id UNIQUEIDENTIFIER)
	DECLARE @PurgeTableInt TABLE (Id Int)
	
	SET @Continue = 1
	WHILE (@Continue > 0)
	BEGIN
		INSERT INTO @PurgeTable SELECT DISTINCT TOP 100 co.Id AS Id FROM CustomerOrder co (NOLOCK) 
			LEFT JOIN OrderLine ol (NOLOCK) ON ol.CustomerOrderId = co.Id
			WHERE co.Status = ''Cart'' AND co.OrderDate < DATEADD(day, -1, GETDATE()) AND ol.Id IS NULL
		DELETE co FROM CustomerOrder co INNER JOIN @PurgeTable pt ON pt.Id = co.Id
		SET @Continue = @@ROWCOUNT
		DELETE FROM @PurgeTable
	END

	IF NOT EXISTS(SELECT 1 FROM ApplicationSetting WHERE Name = ''ShoppingCartRetentionDays'')
		INSERT INTO ApplicationSetting (Name, Value) VALUES (''ShoppingCartRetentionDays'', ''0'')

	SELECT @RetentionWindow = CASE WHEN Value != 0 THEN CAST(Value AS INT) ELSE 1 END FROM ApplicationSetting WHERE Name = ''ShoppingCartRetentionDays''
	SET @RetentionWindow = -1 * @RetentionWindow
	SET @RetentionDate = DATEADD(day, @RetentionWindow, GETDATE())
	UPDATE co SET co.Status = ''AbandonedCart'' FROM CustomerOrder co (NOLOCK) 
		LEFT JOIN OrderLine ol (NOLOCK) ON ol.CustomerOrderId = co.Id
		WHERE co.Status = ''Cart'' AND co.OrderDate < DATEADD(day, @RetentionWindow, GETDATE()) AND ol.Id IS NOT NULL

	IF NOT EXISTS(SELECT 1 FROM ApplicationSetting WHERE Name = ''EmailMessagesRetentionDays'')
		INSERT INTO ApplicationSetting (Name, Value) VALUES (''EmailMessagesRetentionDays'', ''60'')

	SELECT @RetentionWindow = CAST(Value AS INT) FROM ApplicationSetting WHERE Name = ''EmailMessagesRetentionDays''
	SET @RetentionWindow = -1 * @RetentionWindow
	SET @RetentionDate = DATEADD(day, @RetentionWindow, GETDATE())
	SET @Continue = 1
	WHILE (@Continue > 0)
	BEGIN
		INSERT INTO @PurgeTable SELECT DISTINCT TOP 100 em.Id AS Id FROM EmailMessage em (NOLOCK) 
			WHERE em.SentDate < @RetentionDate
		DELETE em FROM EmailMessage em INNER JOIN @PurgeTable pt ON pt.Id = em.Id
		SET @Continue = @@ROWCOUNT
		DELETE FROM @PurgeTable
	END

	IF NOT EXISTS(SELECT 1 FROM ApplicationSetting WHERE Name = ''AbandonedCartRetentionDays'')
		INSERT INTO ApplicationSetting (Name, Value) VALUES (''AbandonedCartRetentionDays'', ''90'')

	SELECT @RetentionWindow = CAST(Value AS INT) FROM ApplicationSetting WHERE Name = ''AbandonedCartRetentionDays''
	SET @RetentionWindow = -1 * @RetentionWindow
	SET @RetentionDate = DATEADD(day, @RetentionWindow, GETDATE())
	SET @Continue = 1
	WHILE (@Continue > 0)
	BEGIN
		INSERT INTO @PurgeTable SELECT DISTINCT TOP 100 co.Id FROM CustomerOrder co (NOLOCK) 
			WHERE co.Status = ''Cart'' AND co.OrderDate < @RetentionDate
		DELETE co FROM CustomerOrder co INNER JOIN @PurgeTable pt ON pt.Id = co.Id
		SET @Continue = @@ROWCOUNT
		DELETE FROM @PurgeTable
	END

	IF NOT EXISTS(SELECT 1 FROM ApplicationSetting WHERE Name = ''ApplicationLogRetentionDays'')
		INSERT INTO ApplicationSetting (Name, Value) VALUES (''ApplicationLogRetentionDays'', ''14'')

	SELECT @RetentionWindow = CAST(Value AS INT) FROM ApplicationSetting WHERE Name = ''ApplicationLogRetentionDays''
	SET @RetentionWindow = -1 * @RetentionWindow
	SET @RetentionDate = DATEADD(day, @RetentionWindow, GETDATE())
	SET @Continue = 1
	WHILE (@Continue > 0)
	BEGIN
		INSERT INTO @PurgeTable SELECT TOP 100 al.Id FROM ApplicationLog al (NOLOCK) WHERE al.LogDate < @RetentionDate
		DELETE al FROM ApplicationLog al INNER JOIN @PurgeTable pt ON pt.Id = al.Id
		SET @Continue = @@ROWCOUNT
		DELETE FROM @PurgeTable
	END

	SET @Continue = 1
	WHILE (@Continue > 0)
	BEGIN
		INSERT INTO @PurgeTableInt SELECT TOP 100 ee.Sequence FROM ELMAH_Error ee (NOLOCK) WHERE ee.TimeUtc < @RetentionDate
		DELETE ee FROM ELMAH_Error ee INNER JOIN @PurgeTableInt pt ON pt.Id = ee.Sequence
		SET @Continue = @@ROWCOUNT
		DELETE FROM @PurgeTableInt
	END

	IF NOT EXISTS(SELECT 1 FROM ApplicationSetting WHERE Name = ''IntegrationJobLogRetentionDays'')
		INSERT INTO ApplicationSetting (Name, Value) VALUES (''IntegrationJobLogRetentionDays'', ''14'')

	SELECT @RetentionWindow = CAST(Value AS INT) FROM ApplicationSetting WHERE Name = ''IntegrationJobLogRetentionDays''
	SET @RetentionWindow = -1 * @RetentionWindow
	SET @RetentionDate = DATEADD(day, @RetentionWindow, GETDATE())
	SET @Continue = 1
	WHILE (@Continue > 0)
	BEGIN
		INSERT INTO @PurgeTable SELECT TOP 100 ij.Id FROM IntegrationJob ij (NOLOCK) WHERE ij.StartDateTime < @RetentionDate
		DELETE ij FROM IntegrationJob ij INNER JOIN @PurgeTable pt ON pt.Id = ij.Id
		SET @Continue = @@ROWCOUNT
		DELETE FROM @PurgeTable
	END


	IF NOT EXISTS(SELECT 1 FROM ApplicationSetting WHERE Name = ''RfqOrderRetentionDays'')
		INSERT INTO ApplicationSetting (Name, Value) VALUES (''RfqOrderRetentionDays'', ''90'')

	SELECT @RetentionWindow = CAST(Value AS INT) FROM ApplicationSetting WHERE Name = ''RfqOrderRetentionDays''
	SET @RetentionWindow = -1 * @RetentionWindow
	SET @RetentionDate = DATEADD(day, @RetentionWindow, GETDATE())
	SET @Continue = 1
	WHILE (@Continue > 0)
	BEGIN
		INSERT INTO @PurgeTable 
		SELECT DISTINCT TOP 100 co.Id AS Id 
		FROM	CustomerOrder co (NOLOCK) 
		WHERE	co.Type = ''Quote'' 
				AND (
					(co.QuoteExpirationDate < @RetentionDate AND co.Status IN (''QuoteCreated'',''QuoteProposed'',''QuoteRejected'',''QuoteRequested''))
					OR (co.Status = ''QuoteCreated'' AND co.QuoteExpirationDate IS NULL AND co.OrderDate < @RetentionDate)
					)

		DELETE co FROM CustomerOrder co INNER JOIN @PurgeTable pt ON pt.Id = co.Id
		SET @Continue = @@ROWCOUNT
		DELETE FROM @PurgeTable
	END
	
    EXEC sp_updatestats

	INSERT INTO ApplicationLog (Source, Type, Message) VALUES (''NightlyMaintenance'',''INFO'',''Nightly Maintenance Finished'')
	
END

'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CustomerProduct]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerProduct]', N'CustomerProductId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerProduct]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CustomerProduct].[CustomerProductId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CustomerProduct] on [dbo].[CustomerProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CustomerProduct' AND object_id = OBJECT_ID(N'[dbo].[CustomerProduct]'))
ALTER TABLE [dbo].[CustomerProduct] ADD CONSTRAINT [PK_CustomerProduct] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CustomerProduct_NaturalKey] on [dbo].[CustomerProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerProduct_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CustomerProduct]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CustomerProduct_NaturalKey] ON [dbo].[CustomerProduct] ([CustomerId], [ProductId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[CustomerProduct_After_Update] on [dbo].[CustomerProduct]'
GO
IF OBJECT_ID(N'[dbo].[CustomerProduct_After_Update]', 'TR') IS NULL
EXEC sp_executesql N'-- =============================================
-- Author:		Peter Gaard
-- Create date: 8/25/2014
-- Description:	CustomerProduct Change Trigger
-- =============================================
CREATE TRIGGER [dbo].[CustomerProduct_After_Update] 
   ON  [dbo].[CustomerProduct]
   AFTER INSERT,UPDATE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
    
	UPDATE p SET p.IndexStatus = 1 FROM Product p 		
		JOIN INSERTED i ON i.ProductId = p.Id
		WHERE p.IndexStatus = 0	
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[UserProfile]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[UserProfile]', N'LanguageId') IS NULL
ALTER TABLE [dbo].[UserProfile] ADD[LanguageId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
UPDATE [dbo].[UserProfile] SET [ApplicationName]=(N'/') WHERE [ApplicationName] IS NULL
UPDATE [dbo].[UserProfile] SET [HasRfqUpdates]=((0)) WHERE [HasRfqUpdates] IS NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[UserProfile]', N'UserProfileId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[UserProfile]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[UserProfile].[UserProfileId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [CanChangePassword] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [CanSubmitOrder] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [CanViewAllOrders] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [IsSubscribed] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [ApplicationName] [nvarchar] (256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [SubscriptionUser] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [IsGuest] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [IsReviewingContent] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [LimitExceededNotification] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [IsEditingContent] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [DashboardIsHomepage] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [IsPasswordChangeRequired] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfile] ALTER COLUMN [HasRfqUpdates] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_UserProfile] on [dbo].[UserProfile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_UserProfile' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [PK_UserProfile] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_UserProfile_NaturalKey] on [dbo].[UserProfile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_UserProfile_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_UserProfile_NaturalKey] ON [dbo].[UserProfile] ([UserName], [ApplicationName])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating trigger [dbo].[Category_After_InsertOrUpdate] on [dbo].[Category]'
GO
IF OBJECT_ID(N'[dbo].[Category_After_InsertOrUpdate]', 'TR') IS NULL
EXEC sp_executesql N'-- =============================================
-- Author:		Tom Frishberg
-- Create date: 02/18/2015
-- Description:	To set UrlSegment
-- =============================================
CREATE TRIGGER [dbo].[Category_After_InsertOrUpdate]
   ON  [dbo].[Category]
   AFTER INSERT,UPDATE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Update UrlSegment
	UPDATE c SET c.UrlSegment = dbo.UrlFriendlyString(c.UrlSegment) FROM
	  Category c JOIN Inserted i ON c.Id = i.Id
END
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Warehouse]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Warehouse]', N'CountryId') IS NULL
ALTER TABLE [dbo].[Warehouse] ADD[CountryId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Warehouse]', N'WarehouseId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Warehouse]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Warehouse].[WarehouseId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Warehouse]', N'Zip') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Warehouse]', N'PostalCode') IS NULL)
EXEC sp_rename N'[dbo].[Warehouse].[Zip]', N'PostalCode', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Warehouse]', N'Deactivate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Warehouse]', N'DeactivateOn') IS NULL)
EXEC sp_rename N'[dbo].[Warehouse].[Deactivate]', N'DeactivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Warehouse] ALTER COLUMN [DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Warehouse] ALTER COLUMN [IsDefaultWarehouse] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Warehouse] on [dbo].[Warehouse]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Warehouse' AND object_id = OBJECT_ID(N'[dbo].[Warehouse]'))
ALTER TABLE [dbo].[Warehouse] ADD CONSTRAINT [PK_Warehouse] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Warehouse]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Warehouse_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Warehouse]'))
ALTER TABLE [dbo].[Warehouse] ADD CONSTRAINT [IX_Warehouse_NaturalKey] UNIQUE NONCLUSTERED  ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[OrderHistoryLine]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[OrderHistoryLine]', N'OrderHistoryLineId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[OrderHistoryLine]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[OrderHistoryLine].[OrderHistoryLineId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[OrderHistoryLine] ALTER COLUMN [RequiredDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[OrderHistoryLine] ALTER COLUMN [LastShipDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[OrderHistoryLine] ALTER COLUMN [Description] [nvarchar] (2048) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_OrderHistoryLine] on [dbo].[OrderHistoryLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_OrderHistoryLine' AND object_id = OBJECT_ID(N'[dbo].[OrderHistoryLine]'))
ALTER TABLE [dbo].[OrderHistoryLine] ADD CONSTRAINT [PK_OrderHistoryLine] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_OrderHistoryLine_NaturalKey] on [dbo].[OrderHistoryLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderHistoryLine_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[OrderHistoryLine]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_OrderHistoryLine_NaturalKey] ON [dbo].[OrderHistoryLine] ([OrderHistoryId], [LineNumber], [ReleaseNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[ReportOrderHistoryLineView]'
GO
IF OBJECT_ID(N'[dbo].[ReportOrderHistoryLineView]', 'V') IS NULL
EXEC sp_executesql N'


CREATE VIEW [dbo].[ReportOrderHistoryLineView]
AS
SELECT        
	''OrderHistoryLine'' AS Source, ohl.Id, ohl.OrderHistoryId AS Orderid, ohl.RequiredDate, ohl.LastShipDate, ohl.CustomerNumber, 
    ohl.CustomerSequence, ohl.LineType, ohl.Status, ohl.LineNumber, ohl.ReleaseNumber, ohl.ProductErpNumber, ohl.CustomerProductNumber, ohl.LinePOReference, 
    ohl.Description, ohl.Warehouse, ohl.Notes, ohl.QtyOrdered, ohl.QtyShipped, ohl.UnitOfMeasure, ohl.InventoryQtyOrdered, ohl.InventoryQtyShipped, 
	CASE ISNULL(oh.ConversionRate,0)
		WHEN 0 THEN ohl.UnitPrice
		ELSE ohl.UnitPrice / oh.ConversionRate
	END AS UnitPrice, 
    ohl.DiscountPercent, 
	CASE ISNULL(oh.ConversionRate,0)
		WHEN 0 THEN ohl.DiscountAmount
		ELSE ohl.DiscountAmount / oh.ConversionRate
	END AS DiscountAmount,
	CASE ISNULL(oh.ConversionRate,0)
		WHEN 0 THEN ohl.PromotionAmountApplied
		ELSE ohl.PromotionAmountApplied/ oh.ConversionRate
	END AS PromotionAmountApplied,
	CASE ISNULL(oh.ConversionRate,0)
		WHEN 0 THEN ohl.LineTotal
		ELSE ohl.LineTotal / oh.ConversionRate
	END AS LineTotal,
	ohl.RMAQtyRequested, 
	ohl.RMAQtyReceived,
	oh.ConversionRate
FROM
	OrderHistoryLine ohl WITH (NOLOCK)
	LEFT JOIN OrderHistory oh WITH (NOLOCK) ON ohl.OrderHistoryId = oh.Id
UNION
SELECT
	''OrderLine'' AS Source, ol.Id AS OrderHistoryLineId, ol.CustomerOrderId AS OrderId, ol.DueDate AS RequiredDate, ol.ShipDate AS LastShipDate, 
    co.CustomerNumber, co.CustomerSequence, '''' AS LineType, ol.Status, ol.Line AS LineNumber, ol.Release AS ReleaseNumber, ISNULL(p.ErpDescription, '''') 
    AS ProductErpNumber, ISNULL(cp.Name, ''''), ISNULL(ol.CustomerPOLine, '''') AS LinePOReference, ISNULL(ol.Description, ''''), w.name as Warehouse, ol.Notes, ol.QtyOrdered, 
    ol.QtyShipped, ol.UnitOfMeasure, ol.QtyOrdered AS InventoryQtyOrdered, ol.QtyShipped AS InventoryQtyShipped, 
	CASE ISNULL(co.ConversionRate,0)
		WHEN 0 THEN ol.ActualPrice
		ELSE ol.ActualPrice / co.ConversionRate
	END AS UnitPrice,
	ol.DiscountPercent, 
	CASE ISNULL(co.ConversionRate,0)
		WHEN 0 THEN ol.DiscountAmount
		ELSE ol.DiscountAmount / co.ConversionRate
	END AS DiscountAmount,
	0.00 AS PromotionAmountApplied, 
	CASE ISNULL(co.ConversionRate,0)
		WHEN 0 THEN (ol.QtyOrdered * ol.ActualPrice)
		ELSE (ol.QtyOrdered * ol.ActualPrice) / co.ConversionRate
	END AS LineTotal,
	0.00 AS RMAQtyRequested, 
	0.00 AS RMAQtyReceived,
	co.ConversionRate
FROM 
	CustomerOrder co WITH (NOLOCK) LEFT JOIN
    OrderLine ol WITH (NOLOCK) ON co.Id = ol.CustomerOrderId LEFT JOIN
    Product p WITH (NOLOCK) ON ol.ProductId = p.id LEFT JOIN
    CustomerProduct cp WITH (NOLOCK) ON p.Id = cp.ProductId LEFT JOIN
	Warehouse w WITH(NOLOCK) on w.Id = ol.WarehouseId
WHERE
	co.Status LIKE ''%Aba%'' AND ol.Id IS NOT NULL AND ol.QtyOrdered > 0

	
'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[EmailList]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[EmailList]', N'EmailListId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[EmailList]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[EmailList].[EmailListId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[EmailList] ALTER COLUMN [CanSubscribe] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_EmailList] on [dbo].[EmailList]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_EmailList' AND object_id = OBJECT_ID(N'[dbo].[EmailList]'))
ALTER TABLE [dbo].[EmailList] ADD CONSTRAINT [PK_EmailList] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_EmailList_NaturalKey] on [dbo].[EmailList]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_EmailList_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[EmailList]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_EmailList_NaturalKey] ON [dbo].[EmailList] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[AttributeType]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[AttributeType]', N'FilterSectionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[AttributeType]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[AttributeType].[FilterSectionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[AttributeType] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[AttributeType] ALTER COLUMN [IsFilter] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[AttributeType] ALTER COLUMN [IsComparable] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_AttributeType] on [dbo].[AttributeType]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_AttributeType' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]'))
ALTER TABLE [dbo].[AttributeType] ADD CONSTRAINT [PK_AttributeType] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_AttributeType_NaturalKey] on [dbo].[AttributeType]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_AttributeType_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_AttributeType_NaturalKey] ON [dbo].[AttributeType] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[GiftCard]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[GiftCard]', N'GiftCardType') IS NULL
ALTER TABLE [dbo].[GiftCard] ADD[GiftCardType] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_GiftCard_GiftCardType] DEFAULT ('')
IF COL_LENGTH(N'[dbo].[GiftCard]', N'PIN') IS NULL
ALTER TABLE [dbo].[GiftCard] ADD[PIN] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_GiftCard_PIN] DEFAULT ('')
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[GiftCard]', N'GiftCardId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[GiftCard]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[GiftCard].[GiftCardId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[GiftCard]', N'Purchased') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[GiftCard]', N'PurchasedOn') IS NULL)
EXEC sp_rename N'[dbo].[GiftCard].[Purchased]', N'PurchasedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[GiftCard]', N'Expired') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[GiftCard]', N'ExpiresOn') IS NULL)
EXEC sp_rename N'[dbo].[GiftCard].[Expired]', N'ExpiresOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[GiftCard] ALTER COLUMN [PurchasedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[GiftCard] ALTER COLUMN [ExpiresOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[GiftCard] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_GiftCard] on [dbo].[GiftCard]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_GiftCard' AND object_id = OBJECT_ID(N'[dbo].[GiftCard]'))
ALTER TABLE [dbo].[GiftCard] ADD CONSTRAINT [PK_GiftCard] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_GiftCard_NaturalKey] on [dbo].[GiftCard]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_GiftCard_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[GiftCard]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_GiftCard_NaturalKey] ON [dbo].[GiftCard] ([GiftCardNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ContentPageState]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ContentPageState]', N'ContentPageStateId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ContentPageState]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ContentPageState].[ContentPageStateId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentPageState] ALTER COLUMN [PublishOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentPageState] ALTER COLUMN [FuturePublishOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ContentPageState] on [dbo].[ContentPageState]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ContentPageState' AND object_id = OBJECT_ID(N'[dbo].[ContentPageState]'))
ALTER TABLE [dbo].[ContentPageState] ADD CONSTRAINT [PK_ContentPageState] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[EmailMessageDeliveryAttempt]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[EmailMessageDeliveryAttempt]', N'EmailMessageDeliveryAttemptId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[EmailMessageDeliveryAttempt]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[EmailMessageDeliveryAttempt].[EmailMessageDeliveryAttemptId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[EmailMessageDeliveryAttempt] ALTER COLUMN [AttemptedDateTime] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[EmailMessageDeliveryAttempt] ALTER COLUMN [DeliveredDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_EmailMessageDeliveryAttempt] on [dbo].[EmailMessageDeliveryAttempt]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_EmailMessageDeliveryAttempt' AND object_id = OBJECT_ID(N'[dbo].[EmailMessageDeliveryAttempt]'))
ALTER TABLE [dbo].[EmailMessageDeliveryAttempt] ADD CONSTRAINT [PK_EmailMessageDeliveryAttempt] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ShipRule]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShipRule]', N'ShipRuleId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShipRule]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ShipRule].[ShipRuleId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShipRule]', N'Zip') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShipRule]', N'PostalCode') IS NULL)
EXEC sp_rename N'[dbo].[ShipRule].[Zip]', N'PostalCode', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShipRule]', N'ZipLowerRange') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShipRule]', N'PostalCodeLowerRange') IS NULL)
EXEC sp_rename N'[dbo].[ShipRule].[ZipLowerRange]', N'PostalCodeLowerRange', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShipRule]', N'ZipUpperRange') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShipRule]', N'PostalCodeUpperRange') IS NULL)
EXEC sp_rename N'[dbo].[ShipRule].[ZipUpperRange]', N'PostalCodeUpperRange', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ShipRule] ALTER COLUMN [ShipRuleType] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ShipRule] on [dbo].[ShipRule]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ShipRule' AND object_id = OBJECT_ID(N'[dbo].[ShipRule]'))
ALTER TABLE [dbo].[ShipRule] ADD CONSTRAINT [PK_ShipRule] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CategoryProperty]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CategoryProperty]', N'CategoryPropertyId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CategoryProperty]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CategoryProperty].[CategoryPropertyId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CategoryProperty] on [dbo].[CategoryProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CategoryProperty' AND object_id = OBJECT_ID(N'[dbo].[CategoryProperty]'))
ALTER TABLE [dbo].[CategoryProperty] ADD CONSTRAINT [PK_CategoryProperty] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CategoryProperty_NaturalKey] on [dbo].[CategoryProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CategoryProperty_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CategoryProperty]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CategoryProperty_NaturalKey] ON [dbo].[CategoryProperty] ([CategoryId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[MessageStatus]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[MessageStatus]', N'MessageStatusId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[MessageStatus]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[MessageStatus].[MessageStatusId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[MessageStatus] ALTER COLUMN [HasRead] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_MessageStatus] on [dbo].[MessageStatus]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_MessageStatus' AND object_id = OBJECT_ID(N'[dbo].[MessageStatus]'))
ALTER TABLE [dbo].[MessageStatus] ADD CONSTRAINT [PK_MessageStatus] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_MessageStatus_NaturalKey] on [dbo].[MessageStatus]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_MessageStatus_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[MessageStatus]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_MessageStatus_NaturalKey] ON [dbo].[MessageStatus] ([MessageId], [UserProfileId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[InvoiceHistoryLine]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[InvoiceHistoryLine]', N'InvoiceHistoryLineId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[InvoiceHistoryLine]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[InvoiceHistoryLine].[InvoiceHistoryLineId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_InvoiceHistoryLine] on [dbo].[InvoiceHistoryLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_InvoiceHistoryLine' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistoryLine]'))
ALTER TABLE [dbo].[InvoiceHistoryLine] ADD CONSTRAINT [PK_InvoiceHistoryLine] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_InvoiceHistoryLine_OrderNumber] on [dbo].[InvoiceHistoryLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_InvoiceHistoryLine_OrderNumber' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistoryLine]'))
CREATE NONCLUSTERED INDEX [IX_InvoiceHistoryLine_OrderNumber] ON [dbo].[InvoiceHistoryLine] ([ERPOrderNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_InvoiceHistoryLine_NaturalKey] on [dbo].[InvoiceHistoryLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_InvoiceHistoryLine_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistoryLine]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_InvoiceHistoryLine_NaturalKey] ON [dbo].[InvoiceHistoryLine] ([InvoiceHistoryId], [LineNumber], [ReleaseNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[WebSiteConfiguration]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[WebSiteConfiguration]', N'WebSiteConfigurationId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[WebSiteConfiguration]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[WebSiteConfiguration].[WebSiteConfigurationId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebSiteConfiguration] ALTER COLUMN [Description] [nvarchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_WebSiteConfiguration] on [dbo].[WebSiteConfiguration]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_WebSiteConfiguration' AND object_id = OBJECT_ID(N'[dbo].[WebSiteConfiguration]'))
ALTER TABLE [dbo].[WebSiteConfiguration] ADD CONSTRAINT [PK_WebSiteConfiguration] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_WebSiteConfiguration_NaturalKey] on [dbo].[WebSiteConfiguration]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_WebSiteConfiguration_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[WebSiteConfiguration]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_WebSiteConfiguration_NaturalKey] ON [dbo].[WebSiteConfiguration] ([WebSiteId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ProductWarehouse]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ProductWarehouse]', N'ProductWarehouseId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ProductWarehouse]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ProductWarehouse].[ProductWarehouseId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ProductWarehouse] ALTER COLUMN [IsDiscontinued] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ProductWarehouse] on [dbo].[ProductWarehouse]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ProductWarehouse' AND object_id = OBJECT_ID(N'[dbo].[ProductWarehouse]'))
ALTER TABLE [dbo].[ProductWarehouse] ADD CONSTRAINT [PK_ProductWarehouse] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ProductWarehouse_NaturalKey] on [dbo].[ProductWarehouse]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ProductWarehouse_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[ProductWarehouse]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ProductWarehouse_NaturalKey] ON [dbo].[ProductWarehouse] ([ProductId], [WarehouseId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[EmailSubscriber]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[EmailSubscriber]', N'EmailSubscriberId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[EmailSubscriber]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[EmailSubscriber].[EmailSubscriberId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[EmailSubscriber]', N'CreateDate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[EmailSubscriber]', N'CreatedOn') IS NULL)
EXEC sp_rename N'[dbo].[EmailSubscriber].[CreateDate]', N'CreatedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[EmailSubscriber] ALTER COLUMN [CreatedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_EmailSubscriber] on [dbo].[EmailSubscriber]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_EmailSubscriber' AND object_id = OBJECT_ID(N'[dbo].[EmailSubscriber]'))
ALTER TABLE [dbo].[EmailSubscriber] ADD CONSTRAINT [PK_EmailSubscriber] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_EmailSubscriber_NaturalKey] on [dbo].[EmailSubscriber]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_EmailSubscriber_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[EmailSubscriber]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_EmailSubscriber_NaturalKey] ON [dbo].[EmailSubscriber] ([Email])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CategoryAttributeType]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CategoryAttributeType]', N'CategoryFilterSectionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CategoryAttributeType]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CategoryAttributeType].[CategoryFilterSectionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CategoryAttributeType]', N'FilterSectionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CategoryAttributeType]', N'AttributeTypeId') IS NULL)
EXEC sp_rename N'[dbo].[CategoryAttributeType].[FilterSectionId]', N'AttributeTypeId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CategoryAttributeType] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CategoryAttributeType] ALTER COLUMN [DetailDisplaySequence] [tinyint] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CategoryAttributeType] on [dbo].[CategoryAttributeType]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CategoryAttributeType' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]'))
ALTER TABLE [dbo].[CategoryAttributeType] ADD CONSTRAINT [PK_CategoryAttributeType] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CategoryAttributeType_NaturalKey] on [dbo].[CategoryAttributeType]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CategoryAttributeType_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CategoryAttributeType_NaturalKey] ON [dbo].[CategoryAttributeType] ([CategoryId], [AttributeTypeId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ConfigurationOption]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ConfigurationOption]', N'ConfigurationOptionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ConfigurationOption]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ConfigurationOption].[ConfigurationOptionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [IsVisible] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [IsRequired] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [SetAsFutureDefault] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [IncludeInLineDescription] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [TextIsMultiline] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [NumberMinValue] [decimal] (18, 5) NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [NumberMaxValue] [decimal] (18, 5) NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [NumberDecimals] [decimal] (18, 5) NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [DateCheckRange] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [ComboConditionalList] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [ComboMultiSelect] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [ComboIsProduct] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [ComboProductSeparateLine] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOption] ALTER COLUMN [ComboProductPriceSeparately] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ConfigurationOption] on [dbo].[ConfigurationOption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ConfigurationOption' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [PK_ConfigurationOption] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ConfigurationOption_ConfigurationPageId_Name] on [dbo].[ConfigurationOption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ConfigurationOption_ConfigurationPageId_Name' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ConfigurationOption_ConfigurationPageId_Name] ON [dbo].[ConfigurationOption] ([ConfigurationPageId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[TaxExemption]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[TaxExemption]', N'TaxExemptionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[TaxExemption]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[TaxExemption].[TaxExemptionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[TaxExemption]', N'Active') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[TaxExemption]', N'ActivateOn') IS NULL)
EXEC sp_rename N'[dbo].[TaxExemption].[Active]', N'ActivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[TaxExemption]', N'Deactivate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[TaxExemption]', N'DeactivateOn') IS NULL)
EXEC sp_rename N'[dbo].[TaxExemption].[Deactivate]', N'DeactivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[TaxExemption] ALTER COLUMN [ActivateOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[TaxExemption] ALTER COLUMN [DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_TaxExemption] on [dbo].[TaxExemption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_TaxExemption' AND object_id = OBJECT_ID(N'[dbo].[TaxExemption]'))
ALTER TABLE [dbo].[TaxExemption] ADD CONSTRAINT [PK_TaxExemption] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_TaxExemption_NaturalKey] on [dbo].[TaxExemption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_TaxExemption_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[TaxExemption]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_TaxExemption_NaturalKey] ON [dbo].[TaxExemption] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ShippingRestriction]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShippingRestriction]', N'RestrictionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShippingRestriction]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ShippingRestriction].[RestrictionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ShippingRestriction] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ShippingRestriction] on [dbo].[ShippingRestriction]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ShippingRestriction' AND object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]'))
ALTER TABLE [dbo].[ShippingRestriction] ADD CONSTRAINT [PK_ShippingRestriction] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ShippingRestriction_NaturalKey] on [dbo].[ShippingRestriction]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ShippingRestriction_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ShippingRestriction_NaturalKey] ON [dbo].[ShippingRestriction] ([StateId], [CategoryId], [ProductId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[MiscellaneousCode]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[MiscellaneousCode]', N'MiscellaneousCodeId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[MiscellaneousCode]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[MiscellaneousCode].[MiscellaneousCodeId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[MiscellaneousCode]', N'DeactivateDate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[MiscellaneousCode]', N'DeactivateOn') IS NULL)
EXEC sp_rename N'[dbo].[MiscellaneousCode].[DeactivateDate]', N'DeactivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[MiscellaneousCode] ALTER COLUMN [AdditionalInfo] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[MiscellaneousCode] ALTER COLUMN [DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[MiscellaneousCode] ALTER COLUMN [Description] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_MiscellaneousCode] on [dbo].[MiscellaneousCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_MiscellaneousCode' AND object_id = OBJECT_ID(N'[dbo].[MiscellaneousCode]'))
ALTER TABLE [dbo].[MiscellaneousCode] ADD CONSTRAINT [PK_MiscellaneousCode] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_MiscellaneousCode_NaturalKey] on [dbo].[MiscellaneousCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_MiscellaneousCode_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[MiscellaneousCode]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_MiscellaneousCode_NaturalKey] ON [dbo].[MiscellaneousCode] ([ParentId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PunchOutOrderRequestItemOut]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutOrderRequestItemOut]', N'PunchOutOrderRequestItemOutId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutOrderRequestItemOut]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutOrderRequestItemOut].[PunchOutOrderRequestItemOutId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutOrderRequestItemOut]', N'CreateDate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutOrderRequestItemOut]', N'CreatedOn') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutOrderRequestItemOut].[CreateDate]', N'CreatedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ALTER COLUMN [CreatedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ALTER COLUMN [BillToStreet2] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ALTER COLUMN [BillToStreet3] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ALTER COLUMN [BillToStreet4] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ALTER COLUMN [ShipToStreet2] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ALTER COLUMN [ShipToStreet3] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ALTER COLUMN [ShipToStreet4] [nvarchar] (128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PunchOutOrderRequestItemOut] on [dbo].[PunchOutOrderRequestItemOut]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PunchOutOrderRequestItemOut' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [PK_PunchOutOrderRequestItemOut] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_PunchOutOrderRequestItemOut_OrderLine] on [dbo].[PunchOutOrderRequestItemOut]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PunchOutOrderRequestItemOut_OrderLine' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]'))
CREATE NONCLUSTERED INDEX [IX_PunchOutOrderRequestItemOut_OrderLine] ON [dbo].[PunchOutOrderRequestItemOut] ([OrderLineId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_PunchOutOrderRequestItemOut_OrderRequestId] on [dbo].[PunchOutOrderRequestItemOut]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PunchOutOrderRequestItemOut_OrderRequestId' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]'))
CREATE NONCLUSTERED INDEX [IX_PunchOutOrderRequestItemOut_OrderRequestId] ON [dbo].[PunchOutOrderRequestItemOut] ([PunchOutOrderRequestId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ConfigurationConditionFilter]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ConfigurationConditionFilter]', N'ConfigurationConditionFilterId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ConfigurationConditionFilter]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ConfigurationConditionFilter].[ConfigurationConditionFilterId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ConfigurationConditionFilter] on [dbo].[ConfigurationConditionFilter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ConfigurationConditionFilter' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationConditionFilter]'))
ALTER TABLE [dbo].[ConfigurationConditionFilter] ADD CONSTRAINT [PK_ConfigurationConditionFilter] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[JobDefinitionParameter]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[JobDefinitionParameter]', N'IntegrationJobDefinitionPostprocessorParameterId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[JobDefinitionParameter]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[JobDefinitionParameter].[IntegrationJobDefinitionPostprocessorParameterId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[JobDefinitionParameter]', N'IntegrationJobDefinitionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[JobDefinitionParameter]', N'JobDefinitionId') IS NULL)
EXEC sp_rename N'[dbo].[JobDefinitionParameter].[IntegrationJobDefinitionId]', N'JobDefinitionId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinitionParameter] ALTER COLUMN [DefaultValue] [nvarchar] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinitionParameter] ALTER COLUMN [Prompt] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_JobDefinitionParameter] on [dbo].[JobDefinitionParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_JobDefinitionParameter' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]'))
ALTER TABLE [dbo].[JobDefinitionParameter] ADD CONSTRAINT [PK_JobDefinitionParameter] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_JobDefinitionParameter_Name] on [dbo].[JobDefinitionParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_JobDefinitionParameter_Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_JobDefinitionParameter_Name] ON [dbo].[JobDefinitionParameter] ([JobDefinitionId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[SubscriptionLine]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[SubscriptionLine]', N'SubscriptionLineId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[SubscriptionLine]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[SubscriptionLine].[SubscriptionLineId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_SubscriptionLine] on [dbo].[SubscriptionLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_SubscriptionLine' AND object_id = OBJECT_ID(N'[dbo].[SubscriptionLine]'))
ALTER TABLE [dbo].[SubscriptionLine] ADD CONSTRAINT [PK_SubscriptionLine] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_SubscriptionLine_NaturalKey] on [dbo].[SubscriptionLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_SubscriptionLine_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[SubscriptionLine]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_SubscriptionLine_NaturalKey] ON [dbo].[SubscriptionLine] ([SubscriptionId], [ProductId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[SubscriptionProduct]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[SubscriptionProduct]', N'SubscriptionProductId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[SubscriptionProduct]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[SubscriptionProduct].[SubscriptionProductId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_SubscriptionProduct] on [dbo].[SubscriptionProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_SubscriptionProduct' AND object_id = OBJECT_ID(N'[dbo].[SubscriptionProduct]'))
ALTER TABLE [dbo].[SubscriptionProduct] ADD CONSTRAINT [PK_SubscriptionProduct] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_SubscriptionProduct_ParentProduct] on [dbo].[SubscriptionProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_SubscriptionProduct_ParentProduct' AND object_id = OBJECT_ID(N'[dbo].[SubscriptionProduct]'))
CREATE NONCLUSTERED INDEX [IX_SubscriptionProduct_ParentProduct] ON [dbo].[SubscriptionProduct] ([ParentProductId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_SubscriptionProduct_NaturalKey] on [dbo].[SubscriptionProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_SubscriptionProduct_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[SubscriptionProduct]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_SubscriptionProduct_NaturalKey] ON [dbo].[SubscriptionProduct] ([ProductId], [ParentProductId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[MessageTarget]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[MessageTarget]', N'MessageTargetId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[MessageTarget]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[MessageTarget].[MessageTargetId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_MessageTarget] on [dbo].[MessageTarget]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_MessageTarget' AND object_id = OBJECT_ID(N'[dbo].[MessageTarget]'))
ALTER TABLE [dbo].[MessageTarget] ADD CONSTRAINT [PK_MessageTarget] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_MessageTarget_NaturalKey] on [dbo].[MessageTarget]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_MessageTarget_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[MessageTarget]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_MessageTarget_NaturalKey] ON [dbo].[MessageTarget] ([MessageId], [TargetType], [TargetKey])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[TranslationDictionary]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[TranslationDictionary]', N'LanguageId') IS NULL
ALTER TABLE [dbo].[TranslationDictionary] ADD[LanguageId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[TranslationDictionary]', N'TranslationDictionaryId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[TranslationDictionary]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[TranslationDictionary].[TranslationDictionaryId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_TranslationDictionary] on [dbo].[TranslationDictionary]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_TranslationDictionary' AND object_id = OBJECT_ID(N'[dbo].[TranslationDictionary]'))
ALTER TABLE [dbo].[TranslationDictionary] ADD CONSTRAINT [PK_TranslationDictionary] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_TranslationDictionary_SourceKeywordLanguageCode] on [dbo].[TranslationDictionary]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_TranslationDictionary_SourceKeywordLanguageCode' AND object_id = OBJECT_ID(N'[dbo].[TranslationDictionary]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_TranslationDictionary_SourceKeywordLanguageCode] ON [dbo].[TranslationDictionary] ([LanguageCode], [Source], [Keyword])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_TranslationDictionary] on [dbo].[TranslationDictionary]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_TranslationDictionary' AND object_id = OBJECT_ID(N'[dbo].[TranslationDictionary]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_TranslationDictionary] ON [dbo].[TranslationDictionary] ([Source], [Keyword], [LanguageCode])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ConfigurationQueryResult]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ConfigurationQueryResult]', N'ConfigurationQueryResultId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ConfigurationQueryResult]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ConfigurationQueryResult].[ConfigurationQueryResultId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ConfigurationQueryResults] on [dbo].[ConfigurationQueryResult]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ConfigurationQueryResults' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationQueryResult]'))
ALTER TABLE [dbo].[ConfigurationQueryResult] ADD CONSTRAINT [PK_ConfigurationQueryResults] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[JobDefinitionStep]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[JobDefinitionStep]', N'IntegrationJobDefinitionStepId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[JobDefinitionStep]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[JobDefinitionStep].[IntegrationJobDefinitionStepId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[JobDefinitionStep]', N'IntegrationJobDefinitionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[JobDefinitionStep]', N'JobDefinitionId') IS NULL)
EXEC sp_rename N'[dbo].[JobDefinitionStep].[IntegrationJobDefinitionId]', N'JobDefinitionId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[JobDefinitionStep]', N'IntegrationConnectionOverrideId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[JobDefinitionStep]', N'IntegrationConnectionId') IS NULL)
EXEC sp_rename N'[dbo].[JobDefinitionStep].[IntegrationConnectionOverrideId]', N'IntegrationConnectionId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinitionStep] ALTER COLUMN [SkipHeaderRow] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_JobDefinitionStep] on [dbo].[JobDefinitionStep]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_JobDefinitionStep' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [PK_JobDefinitionStep] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_JobDefinitionStep_Sequence] on [dbo].[JobDefinitionStep]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_JobDefinitionStep_Sequence' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_JobDefinitionStep_Sequence] ON [dbo].[JobDefinitionStep] ([JobDefinitionId], [Sequence])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ConfigurationQueryResultField]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ConfigurationQueryResultField]', N'ConfigurationQueryResultFieldId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ConfigurationQueryResultField]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ConfigurationQueryResultField].[ConfigurationQueryResultFieldId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ConfigurationQueryResultField] on [dbo].[ConfigurationQueryResultField]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ConfigurationQueryResultField' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationQueryResultField]'))
ALTER TABLE [dbo].[ConfigurationQueryResultField] ADD CONSTRAINT [PK_ConfigurationQueryResultField] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[GiftCardTransaction]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[GiftCardTransaction]', N'GiftCardTransactionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[GiftCardTransaction]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[GiftCardTransaction].[GiftCardTransactionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[GiftCardTransaction] ALTER COLUMN [TransactionDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_GiftCardTransaction] on [dbo].[GiftCardTransaction]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_GiftCardTransaction' AND object_id = OBJECT_ID(N'[dbo].[GiftCardTransaction]'))
ALTER TABLE [dbo].[GiftCardTransaction] ADD CONSTRAINT [PK_GiftCardTransaction] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_GiftCardTransaction_NaturalKey] on [dbo].[GiftCardTransaction]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_GiftCardTransaction_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[GiftCardTransaction]'))
CREATE NONCLUSTERED INDEX [IX_GiftCardTransaction_NaturalKey] ON [dbo].[GiftCardTransaction] ([GiftCardId], [CustomerOrderId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ConfigurationQueryResultValue]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ConfigurationQueryResultValue]', N'ConfigurationQueryResultValueId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ConfigurationQueryResultValue]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ConfigurationQueryResultValue].[ConfigurationQueryResultValueId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ConfigurationQueryResultValue] on [dbo].[ConfigurationQueryResultValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ConfigurationQueryResultValue' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationQueryResultValue]'))
ALTER TABLE [dbo].[ConfigurationQueryResultValue] ADD CONSTRAINT [PK_ConfigurationQueryResultValue] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CustomerCostCode]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerCostCode]', N'CustomerCostCodeId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerCostCode]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CustomerCostCode].[CustomerCostCodeId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerCostCode] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CustomerCostCode] on [dbo].[CustomerCostCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CustomerCostCode' AND object_id = OBJECT_ID(N'[dbo].[CustomerCostCode]'))
ALTER TABLE [dbo].[CustomerCostCode] ADD CONSTRAINT [PK_CustomerCostCode] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CustomerCostCode_NaturalKey] on [dbo].[CustomerCostCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerCostCode_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CustomerCostCode]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CustomerCostCode_NaturalKey] ON [dbo].[CustomerCostCode] ([CustomerId], [CostCode])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[OrderLineRfq]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[OrderLineRfq]', N'OrderLineRfqId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[OrderLineRfq]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[OrderLineRfq].[OrderLineRfqId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_OrderLineRfq] on [dbo].[OrderLineRfq]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_OrderLineRfq' AND object_id = OBJECT_ID(N'[dbo].[OrderLineRfq]'))
ALTER TABLE [dbo].[OrderLineRfq] ADD CONSTRAINT [PK_OrderLineRfq] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[UserProfileProperty]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[UserProfileProperty]', N'UserProfilePropertyId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[UserProfileProperty]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[UserProfileProperty].[UserProfilePropertyId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_UserProfileProperty] on [dbo].[UserProfileProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_UserProfileProperty' AND object_id = OBJECT_ID(N'[dbo].[UserProfileProperty]'))
ALTER TABLE [dbo].[UserProfileProperty] ADD CONSTRAINT [PK_UserProfileProperty] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_UserProfileProperty_NaturalKey] on [dbo].[UserProfileProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_UserProfileProperty_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[UserProfileProperty]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_UserProfileProperty_NaturalKey] ON [dbo].[UserProfileProperty] ([UserProfileId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Vendor]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Vendor]', N'CountryId') IS NULL
ALTER TABLE [dbo].[Vendor] ADD[CountryId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Vendor]', N'VendorId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Vendor]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Vendor].[VendorId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Vendor]', N'Zip') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Vendor]', N'PostalCode') IS NULL)
EXEC sp_rename N'[dbo].[Vendor].[Zip]', N'PostalCode', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Vendor] on [dbo].[Vendor]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Vendor' AND object_id = OBJECT_ID(N'[dbo].[Vendor]'))
ALTER TABLE [dbo].[Vendor] ADD CONSTRAINT [PK_Vendor] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Vendor_NaturalKey] on [dbo].[Vendor]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Vendor_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Vendor]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Vendor_NaturalKey] ON [dbo].[Vendor] ([VendorNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[OrderLineProperty]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[OrderLineProperty]', N'OrderLineAttributeId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[OrderLineProperty]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[OrderLineProperty].[OrderLineAttributeId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_OrderLineProperty] on [dbo].[OrderLineProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_OrderLineProperty' AND object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]'))
ALTER TABLE [dbo].[OrderLineProperty] ADD CONSTRAINT [PK_OrderLineProperty] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_OrderLineProperty_NaturalKey] on [dbo].[OrderLineProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderLineProperty_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_OrderLineProperty_NaturalKey] ON [dbo].[OrderLineProperty] ([OrderLineId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[TranslationProperty]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[TranslationProperty]', N'LanguageId') IS NULL
ALTER TABLE [dbo].[TranslationProperty] ADD[LanguageId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[TranslationProperty]', N'TranslationPropertyId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[TranslationProperty]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[TranslationProperty].[TranslationPropertyId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[TranslationProperty] ALTER COLUMN [TranslatedValue] [nvarchar] (2048) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_TranslationProperty] on [dbo].[TranslationProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_TranslationProperty' AND object_id = OBJECT_ID(N'[dbo].[TranslationProperty]'))
ALTER TABLE [dbo].[TranslationProperty] ADD CONSTRAINT [PK_TranslationProperty] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_TranslationProperty_NaturalKey] on [dbo].[TranslationProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_TranslationProperty_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[TranslationProperty]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_TranslationProperty_NaturalKey] ON [dbo].[TranslationProperty] ([LanguageCode], [ParentTable], [ParentId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_TranslationProperty_ParentTable] on [dbo].[TranslationProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_TranslationProperty_ParentTable' AND object_id = OBJECT_ID(N'[dbo].[TranslationProperty]'))
CREATE NONCLUSTERED INDEX [IX_TranslationProperty_ParentTable] ON [dbo].[TranslationProperty] ([ParentTable]) INCLUDE ([LanguageCode], [ParentId], [TranslatedValue])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_TranslationProperty_ParentNameLanguage] on [dbo].[TranslationProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_TranslationProperty_ParentNameLanguage' AND object_id = OBJECT_ID(N'[dbo].[TranslationProperty]'))
CREATE NONCLUSTERED INDEX [IX_TranslationProperty_ParentNameLanguage] ON [dbo].[TranslationProperty] ([ParentTable], [ParentId], [Name], [LanguageId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CustomerProductSet]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerProductSet]', N'CustomerProductSetId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerProductSet]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CustomerProductSet].[CustomerProductSetId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerProductSet]', N'Active') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerProductSet]', N'ActivateOn') IS NULL)
EXEC sp_rename N'[dbo].[CustomerProductSet].[Active]', N'ActivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerProductSet]', N'Deactivate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerProductSet]', N'DeactivateOn') IS NULL)
EXEC sp_rename N'[dbo].[CustomerProductSet].[Deactivate]', N'DeactivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerProductSet] ALTER COLUMN [ActivateOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerProductSet] ALTER COLUMN [DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CustomerProductSet] on [dbo].[CustomerProductSet]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CustomerProductSet' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]'))
ALTER TABLE [dbo].[CustomerProductSet] ADD CONSTRAINT [PK_CustomerProductSet] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CustomerProductSet_NaturalKey] on [dbo].[CustomerProductSet]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerProductSet_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CustomerProductSet_NaturalKey] ON [dbo].[CustomerProductSet] ([CustomerId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PromotionResult]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PromotionResult]', N'PromotionResultId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PromotionResult]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PromotionResult].[PromotionResultId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PromotionResult] ALTER COLUMN [Visible] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PromotionResult] ALTER COLUMN [IsPercent] [bit] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PromotionResult] on [dbo].[PromotionResult]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PromotionResult' AND object_id = OBJECT_ID(N'[dbo].[PromotionResult]'))
ALTER TABLE [dbo].[PromotionResult] ADD CONSTRAINT [PK_PromotionResult] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_PromotionResult_PromotionId] on [dbo].[PromotionResult]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PromotionResult_PromotionId' AND object_id = OBJECT_ID(N'[dbo].[PromotionResult]'))
CREATE NONCLUSTERED INDEX [IX_PromotionResult_PromotionId] ON [dbo].[PromotionResult] ([PromotionId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[IntegrationConnection]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[IntegrationConnection]', N'IntegrationConnectionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[IntegrationConnection]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[IntegrationConnection].[IntegrationConnectionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[IntegrationConnection] ALTER COLUMN [DebuggingEnabled] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_IntegrationConnection] on [dbo].[IntegrationConnection]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_IntegrationConnection' AND object_id = OBJECT_ID(N'[dbo].[IntegrationConnection]'))
ALTER TABLE [dbo].[IntegrationConnection] ADD CONSTRAINT [PK_IntegrationConnection] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_IntegrationConnection_NaturalKey] on [dbo].[IntegrationConnection]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationConnection_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[IntegrationConnection]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_IntegrationConnection_NaturalKey] ON [dbo].[IntegrationConnection] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[OrderLineConfigurationValue]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[OrderLineConfigurationValue]', N'OrderLineConfigurationValueId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[OrderLineConfigurationValue]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[OrderLineConfigurationValue].[OrderLineConfigurationValueId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_OrderLineConfigurationValue] on [dbo].[OrderLineConfigurationValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_OrderLineConfigurationValue' AND object_id = OBJECT_ID(N'[dbo].[OrderLineConfigurationValue]'))
ALTER TABLE [dbo].[OrderLineConfigurationValue] ADD CONSTRAINT [PK_OrderLineConfigurationValue] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[OrderLineRequisition]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[OrderLineRequisition]', N'OrderLineRequisitionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[OrderLineRequisition]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[OrderLineRequisition].[OrderLineRequisitionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_OrderLineRequisition] on [dbo].[OrderLineRequisition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_OrderLineRequisition' AND object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]'))
ALTER TABLE [dbo].[OrderLineRequisition] ADD CONSTRAINT [PK_OrderLineRequisition] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_OrderLineRequisition_NaturalKey] on [dbo].[OrderLineRequisition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderLineRequisition_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_OrderLineRequisition_NaturalKey] ON [dbo].[OrderLineRequisition] ([OrderLineId], [OriginalOrderLineId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_OrderLineRequisition_OriginalOrderLineId] on [dbo].[OrderLineRequisition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderLineRequisition_OriginalOrderLineId' AND object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]'))
CREATE NONCLUSTERED INDEX [IX_OrderLineRequisition_OriginalOrderLineId] ON [dbo].[OrderLineRequisition] ([OriginalOrderLineId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CustomerBudget]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerBudget]', N'CustomerBudgetId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerBudget]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CustomerBudget].[CustomerBudgetId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CustomerBudget] on [dbo].[CustomerBudget]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CustomerBudget' AND object_id = OBJECT_ID(N'[dbo].[CustomerBudget]'))
ALTER TABLE [dbo].[CustomerBudget] ADD CONSTRAINT [PK_CustomerBudget] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CustomerBudget_NaturalKey] on [dbo].[CustomerBudget]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerBudget_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CustomerBudget]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CustomerBudget_NaturalKey] ON [dbo].[CustomerBudget] ([CustomerId], [ShipToCustomerId], [UserProfileId], [FiscalYear])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[JobDefinitionStepFieldMap]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[JobDefinitionStepFieldMap]', N'IntegrationJobDefinitionStepFieldMapId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[JobDefinitionStepFieldMap]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[JobDefinitionStepFieldMap].[IntegrationJobDefinitionStepFieldMapId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[JobDefinitionStepFieldMap]', N'IntegrationJobDefinitionStepId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[JobDefinitionStepFieldMap]', N'JobDefinitionStepId') IS NULL)
EXEC sp_rename N'[dbo].[JobDefinitionStepFieldMap].[IntegrationJobDefinitionStepId]', N'JobDefinitionStepId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] ALTER COLUMN [Overwrite] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] ALTER COLUMN [IsErpKey] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_JobDefinitionStepFieldMap] on [dbo].[JobDefinitionStepFieldMap]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_JobDefinitionStepFieldMap' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] ADD CONSTRAINT [PK_JobDefinitionStepFieldMap] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_JobDefinitionStepFieldMap] on [dbo].[JobDefinitionStepFieldMap]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_JobDefinitionStepFieldMap' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]'))
CREATE NONCLUSTERED INDEX [IX_JobDefinitionStepFieldMap] ON [dbo].[JobDefinitionStepFieldMap] ([JobDefinitionStepId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CustomerUserProfile]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerUserProfile]', N'CustomerUserProfileId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerUserProfile]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CustomerUserProfile].[CustomerUserProfileId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CustomerUserProfile] ALTER COLUMN [IsDefault] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CustomerUserProfile] on [dbo].[CustomerUserProfile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CustomerUserProfile' AND object_id = OBJECT_ID(N'[dbo].[CustomerUserProfile]'))
ALTER TABLE [dbo].[CustomerUserProfile] ADD CONSTRAINT [PK_CustomerUserProfile] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CustomerUserProfile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerUserProfile_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CustomerUserProfile]'))
ALTER TABLE [dbo].[CustomerUserProfile] ADD CONSTRAINT [IX_CustomerUserProfile_NaturalKey] UNIQUE NONCLUSTERED  ([CustomerId], [UserProfileId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[AttributeValue]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[AttributeValue]', N'ImagePath') IS NULL
ALTER TABLE [dbo].[AttributeValue] ADD[ImagePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_AttributeValue_ImagePath] DEFAULT ('')
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[AttributeValue]', N'FilterValueId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[AttributeValue]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[AttributeValue].[FilterValueId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[AttributeValue]', N'FilterSectionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[AttributeValue]', N'AttributeTypeId') IS NULL)
EXEC sp_rename N'[dbo].[AttributeValue].[FilterSectionId]', N'AttributeTypeId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[AttributeValue] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_AttributeValue] on [dbo].[AttributeValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_AttributeValue' AND object_id = OBJECT_ID(N'[dbo].[AttributeValue]'))
ALTER TABLE [dbo].[AttributeValue] ADD CONSTRAINT [PK_AttributeValue] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_AttributeValue_NaturalKey] on [dbo].[AttributeValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_AttributeValue_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[AttributeValue]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_AttributeValue_NaturalKey] ON [dbo].[AttributeValue] ([AttributeTypeId], [Value])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PromotionRule]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PromotionRule]', N'PromotionRuleId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PromotionRule]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PromotionRule].[PromotionRuleId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PromotionRule]', N'PaymentTermId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PromotionRule]', N'PaymentMethodId') IS NULL)
EXEC sp_rename N'[dbo].[PromotionRule].[PaymentTermId]', N'PaymentMethodId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PromotionRule]', N'SalesmanId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PromotionRule]', N'SalespersonId') IS NULL)
EXEC sp_rename N'[dbo].[PromotionRule].[SalesmanId]', N'SalespersonId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PromotionRule] ALTER COLUMN [FromDateTime] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PromotionRule] ALTER COLUMN [ToDateTime] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PromotionRule] on [dbo].[PromotionRule]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PromotionRule' AND object_id = OBJECT_ID(N'[dbo].[PromotionRule]'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [PK_PromotionRule] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_PromotionRule_PromotionId] on [dbo].[PromotionRule]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PromotionRule_PromotionId' AND object_id = OBJECT_ID(N'[dbo].[PromotionRule]'))
CREATE NONCLUSTERED INDEX [IX_PromotionRule_PromotionId] ON [dbo].[PromotionRule] ([PromotionId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[JobDefinitionStepParameter]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[JobDefinitionStepParameter]', N'IntegrationJobDefinitionStepParameterId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[JobDefinitionStepParameter]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[JobDefinitionStepParameter].[IntegrationJobDefinitionStepParameterId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[JobDefinitionStepParameter]', N'IntegrationJobDefinitionStepId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[JobDefinitionStepParameter]', N'JobDefinitionStepId') IS NULL)
EXEC sp_rename N'[dbo].[JobDefinitionStepParameter].[IntegrationJobDefinitionStepId]', N'JobDefinitionStepId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinitionStepParameter] ALTER COLUMN [DefaultValue] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinitionStepParameter] ALTER COLUMN [Prompt] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_JobDefinitionStepParameter] on [dbo].[JobDefinitionStepParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_JobDefinitionStepParameter' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] ADD CONSTRAINT [PK_JobDefinitionStepParameter] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_JobDefinitionStepParameter_Name] on [dbo].[JobDefinitionStepParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_JobDefinitionStepParameter_Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_JobDefinitionStepParameter_Name] ON [dbo].[JobDefinitionStepParameter] ([JobDefinitionStepId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CategoryProduct]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[CategoryProduct]', N'Id') IS NULL
ALTER TABLE [dbo].[CategoryProduct] ADD[Id] [uniqueidentifier] NOT NULL CONSTRAINT [DF_CategoryProduct_Id] DEFAULT (newsequentialid())
IF COL_LENGTH(N'[dbo].[CategoryProduct]', N'SortOrder') IS NULL
ALTER TABLE [dbo].[CategoryProduct] ADD[SortOrder] [int] NOT NULL CONSTRAINT [DF_CategoryProduct_SortOrder] DEFAULT ((0))
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CategoryProduct] on [dbo].[CategoryProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CategoryProduct' AND object_id = OBJECT_ID(N'[dbo].[CategoryProduct]'))
ALTER TABLE [dbo].[CategoryProduct] ADD CONSTRAINT [PK_CategoryProduct] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CategoryProduct_NaturalKey] on [dbo].[CategoryProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CategoryProduct_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CategoryProduct]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CategoryProduct_NaturalKey] ON [dbo].[CategoryProduct] ([CategoryId], [ProductId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CategoryProduct_ProductCategory] on [dbo].[CategoryProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CategoryProduct_ProductCategory' AND object_id = OBJECT_ID(N'[dbo].[CategoryProduct]'))
CREATE NONCLUSTERED INDEX [IX_CategoryProduct_ProductCategory] ON [dbo].[CategoryProduct] ([ProductId], [CategoryId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CustomerOrderProperty]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerOrderProperty]', N'CustomerOrderPropertyId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerOrderProperty]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CustomerOrderProperty].[CustomerOrderPropertyId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CustomerOrderProperty] on [dbo].[CustomerOrderProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CustomerOrderProperty' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrderProperty]'))
ALTER TABLE [dbo].[CustomerOrderProperty] ADD CONSTRAINT [PK_CustomerOrderProperty] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CustomerOrderProperty_NaturalKey] on [dbo].[CustomerOrderProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerOrderProperty_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrderProperty]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CustomerOrderProperty_NaturalKey] ON [dbo].[CustomerOrderProperty] ([CustomerOrderId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ConfigurationOptionCondition]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ConfigurationOptionCondition]', N'ConfigurationOptionConditionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ConfigurationOptionCondition]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ConfigurationOptionCondition].[ConfigurationOptionConditionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationOptionCondition] ALTER COLUMN [QueryName] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ConfigurationOptionCondition] on [dbo].[ConfigurationOptionCondition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ConfigurationOptionCondition' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOptionCondition]'))
ALTER TABLE [dbo].[ConfigurationOptionCondition] ADD CONSTRAINT [PK_ConfigurationOptionCondition] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ConfigurationOptionCondition_ConfigurationOptionId_Sequence] on [dbo].[ConfigurationOptionCondition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ConfigurationOptionCondition_ConfigurationOptionId_Sequence' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOptionCondition]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ConfigurationOptionCondition_ConfigurationOptionId_Sequence] ON [dbo].[ConfigurationOptionCondition] ([ConfigurationOptionId], [Sequence])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Audit]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Audit]', N'AuditId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Audit]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Audit].[AuditId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Audit] ALTER COLUMN [AuditDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Audit] on [dbo].[Audit]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Audit' AND object_id = OBJECT_ID(N'[dbo].[Audit]'))
ALTER TABLE [dbo].[Audit] ADD CONSTRAINT [PK_Audit] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Language]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Language]', N'LanguageId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Language]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Language].[LanguageId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Language] ALTER COLUMN [HasDeviceSpecificContent] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Language] ALTER COLUMN [HasPersonaSpecificContent] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Language] ALTER COLUMN [ImageFilePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Language] ALTER COLUMN [IsDefault] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Language] on [dbo].[Language]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Language' AND object_id = OBJECT_ID(N'[dbo].[Language]'))
ALTER TABLE [dbo].[Language] ADD CONSTRAINT [PK_Language] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Language_NaturalKey] on [dbo].[Language]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Language_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Language]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Language_NaturalKey] ON [dbo].[Language] ([LanguageCode])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ProductProperty]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ProductProperty]', N'ProductPropertyId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ProductProperty]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ProductProperty].[ProductPropertyId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ProductProperty] on [dbo].[ProductProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ProductProperty' AND object_id = OBJECT_ID(N'[dbo].[ProductProperty]'))
ALTER TABLE [dbo].[ProductProperty] ADD CONSTRAINT [PK_ProductProperty] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ProductProperty_NaturalKey] on [dbo].[ProductProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ProductProperty_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[ProductProperty]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ProductProperty_NaturalKey] ON [dbo].[ProductProperty] ([ProductId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CustomerProductSetProduct]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerProductSetProduct]', N'CustomerProductSetProductId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerProductSetProduct]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CustomerProductSetProduct].[CustomerProductSetProductId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CustomerProductSetProduct] on [dbo].[CustomerProductSetProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CustomerProductSetProduct' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductSetProduct]'))
ALTER TABLE [dbo].[CustomerProductSetProduct] ADD CONSTRAINT [PK_CustomerProductSetProduct] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[BudgetCalendar]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[BudgetCalendar]', N'FiscalYearEndDate') IS NULL
ALTER TABLE [dbo].[BudgetCalendar] ADD[FiscalYearEndDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[BudgetCalendar]', N'BudgetCalendarId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[BudgetCalendar]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[BudgetCalendar].[BudgetCalendarId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period1StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period2StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period3StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period4StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period5StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period6StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period7StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period8StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period9StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period10StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period11StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period12StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[BudgetCalendar] ALTER COLUMN [Period13StartDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_BudgetCalendar] on [dbo].[BudgetCalendar]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_BudgetCalendar' AND object_id = OBJECT_ID(N'[dbo].[BudgetCalendar]'))
ALTER TABLE [dbo].[BudgetCalendar] ADD CONSTRAINT [PK_BudgetCalendar] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_BudgetCalendar_NaturalKey] on [dbo].[BudgetCalendar]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_BudgetCalendar_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[BudgetCalendar]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_BudgetCalendar_NaturalKey] ON [dbo].[BudgetCalendar] ([CustomerId], [FiscalYear])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[WishListProduct]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[WishListProduct]', N'SortOrder') IS NULL
ALTER TABLE [dbo].[WishListProduct] ADD[SortOrder] [int] NOT NULL CONSTRAINT [DF_WishListProduct_Sequence] DEFAULT ((0))
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[WishListProduct]', N'WishListProductId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[WishListProduct]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[WishListProduct].[WishListProductId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_WishListProduct] on [dbo].[WishListProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_WishListProduct' AND object_id = OBJECT_ID(N'[dbo].[WishListProduct]'))
ALTER TABLE [dbo].[WishListProduct] ADD CONSTRAINT [PK_WishListProduct] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_WishListProduct_Sequence] on [dbo].[WishListProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_WishListProduct_Sequence' AND object_id = OBJECT_ID(N'[dbo].[WishListProduct]'))
CREATE NONCLUSTERED INDEX [IX_WishListProduct_Sequence] ON [dbo].[WishListProduct] ([WishListId], [SortOrder])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[WishListProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_WishList_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[WishListProduct]'))
ALTER TABLE [dbo].[WishListProduct] ADD CONSTRAINT [IX_WishList_NaturalKey] UNIQUE NONCLUSTERED  ([WishListId], [ProductId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CustomerProperty]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerProperty]', N'CustomerPropertyId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerProperty]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CustomerProperty].[CustomerPropertyId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CustomerProperty] on [dbo].[CustomerProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CustomerProperty' AND object_id = OBJECT_ID(N'[dbo].[CustomerProperty]'))
ALTER TABLE [dbo].[CustomerProperty] ADD CONSTRAINT [PK_CustomerProperty] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CustomerProperty_NaturalKey] on [dbo].[CustomerProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomerProperty_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CustomerProperty]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CustomerProperty_NaturalKey] ON [dbo].[CustomerProperty] ([CustomerId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CustomerSalesperson]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomerSalesperson]', N'SalesmanId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomerSalesperson]', N'SalespersonId') IS NULL)
EXEC sp_rename N'[dbo].[CustomerSalesperson].[SalesmanId]', N'SalespersonId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CustomerSalesperson] on [dbo].[CustomerSalesperson]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CustomerSalesperson' AND object_id = OBJECT_ID(N'[dbo].[CustomerSalesperson]'))
ALTER TABLE [dbo].[CustomerSalesperson] ADD CONSTRAINT [PK_CustomerSalesperson] PRIMARY KEY CLUSTERED  ([CustomerId], [SalespersonId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PunchOutOrderRequestMessage]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[PunchOutOrderRequestMessage]', N'CreatedOn') IS NULL
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] ADD[CreatedOn] [datetime2] NOT NULL CONSTRAINT [DF_PunchOutOrderRequestMessage_CreateDate] DEFAULT (getdate())
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[PunchOutOrderRequestMessage]', N'CreateDate') IS NOT NULL
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] DROP COLUMN [CreateDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutOrderRequestMessage]', N'PunchOutOrderRequestValidationMessageId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutOrderRequestMessage]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutOrderRequestMessage].[PunchOutOrderRequestValidationMessageId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutOrderRequestMessage]', N'PunchOutOrderRequestValidationMessageType') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutOrderRequestMessage]', N'ValidationMessageType') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutOrderRequestMessage].[PunchOutOrderRequestValidationMessageType]', N'ValidationMessageType', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PunchOutOrderRequestMessage] on [dbo].[PunchOutOrderRequestMessage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PunchOutOrderRequestMessage' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] ADD CONSTRAINT [PK_PunchOutOrderRequestMessage] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ConfigurationPage]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ConfigurationPage]', N'ConfigurationPageId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ConfigurationPage]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ConfigurationPage].[ConfigurationPageId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationPage] ALTER COLUMN [SkipIfNoInputs] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationPage] ALTER COLUMN [SkipScriptsIfNoInputs] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationPage] ALTER COLUMN [OverrideHtmlOutput] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationPage] ALTER COLUMN [OverrideCssOutput] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ConfigurationPage] ALTER COLUMN [OverrideJavaScriptOutput] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ConfigurationPage] on [dbo].[ConfigurationPage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ConfigurationPage' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]'))
ALTER TABLE [dbo].[ConfigurationPage] ADD CONSTRAINT [PK_ConfigurationPage] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CurrencyRate]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CurrencyRate]', N'CurrencyRateId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CurrencyRate]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CurrencyRate].[CurrencyRateId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CurrencyRate] ALTER COLUMN [EffectiveDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CurrencyRate] on [dbo].[CurrencyRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CurrencyRate' AND object_id = OBJECT_ID(N'[dbo].[CurrencyRate]'))
ALTER TABLE [dbo].[CurrencyRate] ADD CONSTRAINT [PK_CurrencyRate] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CurrencyRate_EffectiveDate] on [dbo].[CurrencyRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CurrencyRate_EffectiveDate' AND object_id = OBJECT_ID(N'[dbo].[CurrencyRate]'))
CREATE NONCLUSTERED INDEX [IX_CurrencyRate_EffectiveDate] ON [dbo].[CurrencyRate] ([Id], [EffectiveDate] DESC)
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[RuleType]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[RuleType]', N'RuleTypeId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[RuleType]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[RuleType].[RuleTypeId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_RuleType] on [dbo].[RuleType]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_RuleType' AND object_id = OBJECT_ID(N'[dbo].[RuleType]'))
ALTER TABLE [dbo].[RuleType] ADD CONSTRAINT [PK_RuleType] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_RuleType_NaturalKey] on [dbo].[RuleType]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_RuleType_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[RuleType]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_RuleType_NaturalKey] ON [dbo].[RuleType] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CustomProperty]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CustomProperty]', N'CustomPropertyId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CustomProperty]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CustomProperty].[CustomPropertyId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CustomProperty] on [dbo].[CustomProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CustomProperty' AND object_id = OBJECT_ID(N'[dbo].[CustomProperty]'))
ALTER TABLE [dbo].[CustomProperty] ADD CONSTRAINT [PK_CustomProperty] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CustomProperty_NaturalKey] on [dbo].[CustomProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CustomProperty_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CustomProperty]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CustomProperty_NaturalKey] ON [dbo].[CustomProperty] ([ParentId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[EmailMessageAddress]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[EmailMessageAddress]', N'EmailMessageAddressId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[EmailMessageAddress]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[EmailMessageAddress].[EmailMessageAddressId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_EmailMessageAddress] on [dbo].[EmailMessageAddress]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_EmailMessageAddress' AND object_id = OBJECT_ID(N'[dbo].[EmailMessageAddress]'))
ALTER TABLE [dbo].[EmailMessageAddress] ADD CONSTRAINT [PK_EmailMessageAddress] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[DashboardPanelPosition]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[DashboardPanelPosition]', N'DashboardPanelPositionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[DashboardPanelPosition]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[DashboardPanelPosition].[DashboardPanelPositionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_DashboardPanelPosition] on [dbo].[DashboardPanelPosition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_DashboardPanelPosition' AND object_id = OBJECT_ID(N'[dbo].[DashboardPanelPosition]'))
ALTER TABLE [dbo].[DashboardPanelPosition] ADD CONSTRAINT [PK_DashboardPanelPosition] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[OrderPromotionCode]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[OrderPromotionCode]', N'PromotionCodeId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[OrderPromotionCode]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[OrderPromotionCode].[PromotionCodeId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_OrderPromotionCode] on [dbo].[OrderPromotionCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_OrderPromotionCode' AND object_id = OBJECT_ID(N'[dbo].[OrderPromotionCode]'))
ALTER TABLE [dbo].[OrderPromotionCode] ADD CONSTRAINT [PK_OrderPromotionCode] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_OrderPromotionCode_NaturalKey] on [dbo].[OrderPromotionCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_OrderPromotionCode_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[OrderPromotionCode]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_OrderPromotionCode_NaturalKey] ON [dbo].[OrderPromotionCode] ([CustomerOrderId], [Code])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PunchOutSession]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutSession]', N'PunchOutSessionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutSession]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutSession].[PunchOutSessionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutSession]', N'CreateDate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutSession]', N'CreatedOn') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutSession].[CreateDate]', N'CreatedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutSession] ALTER COLUMN [CreatedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutSession] ALTER COLUMN [ShipAddressIdResolved] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PunchOutSession] on [dbo].[PunchOutSession]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PunchOutSession' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSession]'))
ALTER TABLE [dbo].[PunchOutSession] ADD CONSTRAINT [PK_PunchOutSession] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PunchOutOrderRequest]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutOrderRequest]', N'PunchOutOrderRequestId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutOrderRequest]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutOrderRequest].[PunchOutOrderRequestId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutOrderRequest]', N'CreateDate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutOrderRequest]', N'CreatedOn') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutOrderRequest].[CreateDate]', N'CreatedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [CreatedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [ShippingDescription] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [BillToEmail] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [ShipToEmail] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [BillToStreet2] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [BillToStreet3] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [BillToStreet4] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [BillToTelephoneNumber] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [BillToTelephoneIsoCountryCode] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [BillToTelephoneAreaOrCityCode] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [ShipToStreet2] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [ShipToStreet3] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [ShipToStreet4] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [ShipToTelephoneNumber] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [ShipToTelephoneIsoCountryCode] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutOrderRequest] ALTER COLUMN [ShipToTelephoneAreaOrCityCode] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PunchOutOrderRequest] on [dbo].[PunchOutOrderRequest]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PunchOutOrderRequest' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [PK_PunchOutOrderRequest] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_PunchOutOrderRequest_SessionId] on [dbo].[PunchOutOrderRequest]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PunchOutOrderRequest_SessionId' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]'))
CREATE NONCLUSTERED INDEX [IX_PunchOutOrderRequest_SessionId] ON [dbo].[PunchOutOrderRequest] ([PunchOutSessionId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[IntegrationJobParameter]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[IntegrationJobParameter]', N'IntegrationJobParameterId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[IntegrationJobParameter]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[IntegrationJobParameter].[IntegrationJobParameterId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[IntegrationJobParameter]', N'IntegrationJobDefinitionStepParameterId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[IntegrationJobParameter]', N'JobDefinitionStepParameterId') IS NULL)
EXEC sp_rename N'[dbo].[IntegrationJobParameter].[IntegrationJobDefinitionStepParameterId]', N'JobDefinitionStepParameterId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[IntegrationJobParameter] ALTER COLUMN [Value] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_IntegrationJobParameter] on [dbo].[IntegrationJobParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_IntegrationJobParameter' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJobParameter]'))
ALTER TABLE [dbo].[IntegrationJobParameter] ADD CONSTRAINT [PK_IntegrationJobParameter] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_IntegrationJobParameter_StepParameter] on [dbo].[IntegrationJobParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_IntegrationJobParameter_StepParameter' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJobParameter]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_IntegrationJobParameter_StepParameter] ON [dbo].[IntegrationJobParameter] ([IntegrationJobId], [JobDefinitionStepParameterId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Plugin]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Plugin]', N'PluginId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Plugin]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Plugin].[PluginId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Plugin] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Plugin] on [dbo].[Plugin]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Plugin' AND object_id = OBJECT_ID(N'[dbo].[Plugin]'))
ALTER TABLE [dbo].[Plugin] ADD CONSTRAINT [PK_Plugin] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Plugin_NaturalKey] on [dbo].[Plugin]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Plugin_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Plugin]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Plugin_NaturalKey] ON [dbo].[Plugin] ([Name], [ConnectionName])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[UserProfilePassword]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[UserProfilePassword]', N'UserProfilePasswordId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[UserProfilePassword]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[UserProfilePassword].[UserProfilePasswordId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[UserProfilePassword] ALTER COLUMN [PasswordChangedDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_UserProfilePassword] on [dbo].[UserProfilePassword]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_UserProfilePassword' AND object_id = OBJECT_ID(N'[dbo].[UserProfilePassword]'))
ALTER TABLE [dbo].[UserProfilePassword] ADD CONSTRAINT [PK_UserProfilePassword] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_UserProfilePassword_NaturalKey] on [dbo].[UserProfilePassword]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_UserProfilePassword_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[UserProfilePassword]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_UserProfilePassword_NaturalKey] ON [dbo].[UserProfilePassword] ([UserProfileId], [Password], [PasswordSalt])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PunchOutCustomerUserProfileMap]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutCustomerUserProfileMap]', N'PunchOutCustomerUserProfileMapId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutCustomerUserProfileMap]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutCustomerUserProfileMap].[PunchOutCustomerUserProfileMapId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PunchOutCustomerUserProfileMap] on [dbo].[PunchOutCustomerUserProfileMap]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PunchOutCustomerUserProfileMap' AND object_id = OBJECT_ID(N'[dbo].[PunchOutCustomerUserProfileMap]'))
ALTER TABLE [dbo].[PunchOutCustomerUserProfileMap] ADD CONSTRAINT [PK_PunchOutCustomerUserProfileMap] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_PunchOutCustomerUserProfileMap] on [dbo].[PunchOutCustomerUserProfileMap]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PunchOutCustomerUserProfileMap' AND object_id = OBJECT_ID(N'[dbo].[PunchOutCustomerUserProfileMap]'))
CREATE NONCLUSTERED INDEX [IX_PunchOutCustomerUserProfileMap] ON [dbo].[PunchOutCustomerUserProfileMap] ([UserProfileId], [AddressId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[InvoiceHistory]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[InvoiceHistory]', N'InvoiceHistoryId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[InvoiceHistory]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[InvoiceHistory].[InvoiceHistoryId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[InvoiceHistory] ALTER COLUMN [InvoiceDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[InvoiceHistory] ALTER COLUMN [DueDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[InvoiceHistory] ALTER COLUMN [IsOpen] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_InvoiceHistory] on [dbo].[InvoiceHistory]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_InvoiceHistory' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistory]'))
ALTER TABLE [dbo].[InvoiceHistory] ADD CONSTRAINT [PK_InvoiceHistory] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_InvoiceHistory_SearchColumns] on [dbo].[InvoiceHistory]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_InvoiceHistory_SearchColumns' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistory]'))
CREATE NONCLUSTERED INDEX [IX_InvoiceHistory_SearchColumns] ON [dbo].[InvoiceHistory] ([CustomerNumber], [InvoiceDate]) INCLUDE ([CustomerPO], [CustomerSequence], [InvoiceNumber], [IsOpen])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_InvoiceHistory_NaturalKey] on [dbo].[InvoiceHistory]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_InvoiceHistory_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistory]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_InvoiceHistory_NaturalKey] ON [dbo].[InvoiceHistory] ([InvoiceNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[DealerProperty]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[DealerProperty]', N'DealerPropertyId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[DealerProperty]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[DealerProperty].[DealerPropertyId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_DealerProperty] on [dbo].[DealerProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_DealerProperty' AND object_id = OBJECT_ID(N'[dbo].[DealerProperty]'))
ALTER TABLE [dbo].[DealerProperty] ADD CONSTRAINT [PK_DealerProperty] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_DealerProperty_NaturalKey] on [dbo].[DealerProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_DealerProperty_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[DealerProperty]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_DealerProperty_NaturalKey] ON [dbo].[DealerProperty] ([DealerId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PunchOutOrderRequestExtrinsic]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutOrderRequestExtrinsic]', N'PunchOutOrderRequestExtrinsicId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutOrderRequestExtrinsic]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutOrderRequestExtrinsic].[PunchOutOrderRequestExtrinsicId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PunchOutOrderRequestExtrinsic] on [dbo].[PunchOutOrderRequestExtrinsic]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PunchOutOrderRequestExtrinsic' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestExtrinsic]'))
ALTER TABLE [dbo].[PunchOutOrderRequestExtrinsic] ADD CONSTRAINT [PK_PunchOutOrderRequestExtrinsic] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_PunchOutOrderRequestExtrinsic] on [dbo].[PunchOutOrderRequestExtrinsic]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PunchOutOrderRequestExtrinsic' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestExtrinsic]'))
CREATE NONCLUSTERED INDEX [IX_PunchOutOrderRequestExtrinsic] ON [dbo].[PunchOutOrderRequestExtrinsic] ([PunchOutOrderRequestId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ApplicationMessage]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ApplicationMessage]', N'ApplicationMessageId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ApplicationMessage]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ApplicationMessage].[ApplicationMessageId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ApplicationMessage] on [dbo].[ApplicationMessage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ApplicationMessage' AND object_id = OBJECT_ID(N'[dbo].[ApplicationMessage]'))
ALTER TABLE [dbo].[ApplicationMessage] ADD CONSTRAINT [PK_ApplicationMessage] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ApplicationMessage_NaturalKey] on [dbo].[ApplicationMessage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ApplicationMessage_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[ApplicationMessage]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ApplicationMessage_NaturalKey] ON [dbo].[ApplicationMessage] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Menu]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Menu]', N'LanguageId') IS NULL
ALTER TABLE [dbo].[Menu] ADD[LanguageId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Menu]', N'MenuId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Menu]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Menu].[MenuId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Menu]', N'Image') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Menu]', N'ImagePath') IS NULL)
EXEC sp_rename N'[dbo].[Menu].[Image]', N'ImagePath', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Menu] ALTER COLUMN [Description] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Menu] ALTER COLUMN [ImagePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Menu] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Menu] ALTER COLUMN [Target] [nvarchar] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Menu] ALTER COLUMN [IsGlobalItem] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Menu] ALTER COLUMN [IsSystemItem] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Menu] ALTER COLUMN [ShowInList] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Menu] on [dbo].[Menu]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Menu' AND object_id = OBJECT_ID(N'[dbo].[Menu]'))
ALTER TABLE [dbo].[Menu] ADD CONSTRAINT [PK_Menu] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Menu_NaturalKey] on [dbo].[Menu]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Menu_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Menu]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Menu_NaturalKey] ON [dbo].[Menu] ([ParentId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[DatabaseScript]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[DatabaseScript]', N'DatabaseScriptId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[DatabaseScript]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[DatabaseScript].[DatabaseScriptId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[DatabaseScript]', N'Applied') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[DatabaseScript]', N'AppliedOn') IS NULL)
EXEC sp_rename N'[dbo].[DatabaseScript].[Applied]', N'AppliedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[DatabaseScript] ALTER COLUMN [AppliedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_DatabaseScript] on [dbo].[DatabaseScript]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_DatabaseScript' AND object_id = OBJECT_ID(N'[dbo].[DatabaseScript]'))
ALTER TABLE [dbo].[DatabaseScript] ADD CONSTRAINT [PK_DatabaseScript] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[DictionaryLabel]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[DictionaryLabel]', N'LanguageId') IS NULL
ALTER TABLE [dbo].[DictionaryLabel] ADD[LanguageId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[DictionaryLabel]', N'DictionaryLabelId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[DictionaryLabel]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[DictionaryLabel].[DictionaryLabelId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_DictionaryLabel] on [dbo].[DictionaryLabel]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_DictionaryLabel' AND object_id = OBJECT_ID(N'[dbo].[DictionaryLabel]'))
ALTER TABLE [dbo].[DictionaryLabel] ADD CONSTRAINT [PK_DictionaryLabel] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_DictionaryLabel] on [dbo].[DictionaryLabel]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_DictionaryLabel' AND object_id = OBJECT_ID(N'[dbo].[DictionaryLabel]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_DictionaryLabel] ON [dbo].[DictionaryLabel] ([ApplicationDictionaryId], [LanguageCode], [SystemLabel])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[SearchSynonym]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[SearchSynonym]', N'LanguageId') IS NULL
ALTER TABLE [dbo].[SearchSynonym] ADD[LanguageId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[SearchSynonym]', N'SearchSynonymId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[SearchSynonym]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[SearchSynonym].[SearchSynonymId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[SearchSynonym] ALTER COLUMN [Bidirectional] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_SearchSynonymId] on [dbo].[SearchSynonym]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_SearchSynonymId' AND object_id = OBJECT_ID(N'[dbo].[SearchSynonym]'))
ALTER TABLE [dbo].[SearchSynonym] ADD CONSTRAINT [PK_SearchSynonymId] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[RuleClause]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[RuleClause]', N'RuleClauseId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[RuleClause]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[RuleClause].[RuleClauseId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_RuleClause] on [dbo].[RuleClause]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_RuleClause' AND object_id = OBJECT_ID(N'[dbo].[RuleClause]'))
ALTER TABLE [dbo].[RuleClause] ADD CONSTRAINT [PK_RuleClause] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[WebSiteCurrency]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[WebSiteCurrency]', N'WebSiteCurrencyId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[WebSiteCurrency]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[WebSiteCurrency].[WebSiteCurrencyId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebSiteCurrency] ALTER COLUMN [IsLive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebSiteCurrency] ALTER COLUMN [IsDefault] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_WebSiteCurrency] on [dbo].[WebSiteCurrency]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_WebSiteCurrency' AND object_id = OBJECT_ID(N'[dbo].[WebSiteCurrency]'))
ALTER TABLE [dbo].[WebSiteCurrency] ADD CONSTRAINT [PK_WebSiteCurrency] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_WebSiteCurrency_NaturalKey] on [dbo].[WebSiteCurrency]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_WebSiteCurrency_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[WebSiteCurrency]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_WebSiteCurrency_NaturalKey] ON [dbo].[WebSiteCurrency] ([WebSiteId], [CurrencyId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[DictionaryAttribute]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[DictionaryAttribute]', N'DictionaryAttributeId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[DictionaryAttribute]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[DictionaryAttribute].[DictionaryAttributeId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[DictionaryAttribute] ALTER COLUMN [RequiredField] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[DictionaryAttribute] ALTER COLUMN [IncludeInGrid] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[DictionaryAttribute] ALTER COLUMN [DefaultValue] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_DictionaryAttribute] on [dbo].[DictionaryAttribute]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_DictionaryAttribute' AND object_id = OBJECT_ID(N'[dbo].[DictionaryAttribute]'))
ALTER TABLE [dbo].[DictionaryAttribute] ADD CONSTRAINT [PK_DictionaryAttribute] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[StyleTrait]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[StyleTrait]', N'StyleTraitId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[StyleTrait]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[StyleTrait].[StyleTraitId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[StyleTrait] ALTER COLUMN [Description] [nvarchar] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_StyleTrait] on [dbo].[StyleTrait]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_StyleTrait' AND object_id = OBJECT_ID(N'[dbo].[StyleTrait]'))
ALTER TABLE [dbo].[StyleTrait] ADD CONSTRAINT [PK_StyleTrait] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_StyleTrait_NaturalKey] on [dbo].[StyleTrait]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_StyleTrait_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[StyleTrait]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_StyleTrait_NaturalKey] ON [dbo].[StyleTrait] ([StyleClassId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PunchOutSessionExtrinsic]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutSessionExtrinsic]', N'PunchOutSessionExtrinsicId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutSessionExtrinsic]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutSessionExtrinsic].[PunchOutSessionExtrinsicId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PunchOutSessionExtrinsic] on [dbo].[PunchOutSessionExtrinsic]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PunchOutSessionExtrinsic' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSessionExtrinsic]'))
ALTER TABLE [dbo].[PunchOutSessionExtrinsic] ADD CONSTRAINT [PK_PunchOutSessionExtrinsic] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_PunchOutSessionExtrinsic_Session] on [dbo].[PunchOutSessionExtrinsic]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PunchOutSessionExtrinsic_Session' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSessionExtrinsic]'))
CREATE NONCLUSTERED INDEX [IX_PunchOutSessionExtrinsic_Session] ON [dbo].[PunchOutSessionExtrinsic] ([PunchOutSessionId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PunchOutSessionItemIn]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutSessionItemIn]', N'PunchOutSessionItemInId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutSessionItemIn]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutSessionItemIn].[PunchOutSessionItemInId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PunchOutSessionItemIn] on [dbo].[PunchOutSessionItemIn]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PunchOutSessionItemIn' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSessionItemIn]'))
ALTER TABLE [dbo].[PunchOutSessionItemIn] ADD CONSTRAINT [PK_PunchOutSessionItemIn] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_PunchOutSessionItemIn_Session] on [dbo].[PunchOutSessionItemIn]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_PunchOutSessionItemIn_Session' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSessionItemIn]'))
CREATE NONCLUSTERED INDEX [IX_PunchOutSessionItemIn_Session] ON [dbo].[PunchOutSessionItemIn] ([PunchOutSessionId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ShipCharge]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShipCharge]', N'ShipChargeId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShipCharge]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ShipCharge].[ShipChargeId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ShipCharge] ALTER COLUMN [Description] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ShipCharge] ALTER COLUMN [Enable] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ShipCharge] on [dbo].[ShipCharge]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ShipCharge' AND object_id = OBJECT_ID(N'[dbo].[ShipCharge]'))
ALTER TABLE [dbo].[ShipCharge] ADD CONSTRAINT [PK_ShipCharge] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ShipCharge_NaturalKey] on [dbo].[ShipCharge]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ShipCharge_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[ShipCharge]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ShipCharge_NaturalKey] ON [dbo].[ShipCharge] ([CarrierId], [ShipViaId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CarrierPackage]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CarrierPackage]', N'CarrierPackageId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CarrierPackage]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CarrierPackage].[CarrierPackageId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CarrierPackage] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CarrierPackage] on [dbo].[CarrierPackage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CarrierPackage' AND object_id = OBJECT_ID(N'[dbo].[CarrierPackage]'))
ALTER TABLE [dbo].[CarrierPackage] ADD CONSTRAINT [PK_CarrierPackage] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CarrierPackage_NaturalKey] on [dbo].[CarrierPackage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CarrierPackage_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CarrierPackage]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CarrierPackage_NaturalKey] ON [dbo].[CarrierPackage] ([CarrierId], [Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[UserPaymentProfile]'
GO
IF OBJECT_ID(N'[dbo].[UserPaymentProfile]', 'U') IS NULL
CREATE TABLE [dbo].[UserPaymentProfile]
(
[Id] [uniqueidentifier] NOT NULL CONSTRAINT [DF_UserPaymentProfile_Id] DEFAULT (newsequentialid()),
[UserProfileId] [uniqueidentifier] NOT NULL,
[Description] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_Table_1_Name] DEFAULT (''),
[CardType] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_UserPaymentProfile_CardType] DEFAULT (''),
[ExpirationDate] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_UserPaymentProfile_ExpirationDate] DEFAULT (''),
[MaskedCardNumber] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_UserPaymentProfile_MaskedCardNumber] DEFAULT (''),
[CardIdentifier] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_UserPaymentProfile_PaymentGatewayIdentifier] DEFAULT ('')
)
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_UserPaymentProfile] on [dbo].[UserPaymentProfile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_UserPaymentProfile' AND object_id = OBJECT_ID(N'[dbo].[UserPaymentProfile]'))
ALTER TABLE [dbo].[UserPaymentProfile] ADD CONSTRAINT [PK_UserPaymentProfile] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_UserPaymentProfile_NaturalKey] on [dbo].[UserPaymentProfile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_UserPaymentProfile_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[UserPaymentProfile]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_UserPaymentProfile_NaturalKey] ON [dbo].[UserPaymentProfile] ([UserProfileId], [CardType], [MaskedCardNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[WebSiteLanguage]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[WebSiteLanguage]', N'WebSiteLanguageId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[WebSiteLanguage]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[WebSiteLanguage].[WebSiteLanguageId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebSiteLanguage] ALTER COLUMN [IsDefault] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[WebSiteLanguage] ALTER COLUMN [IsLive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_WebSiteLanguage] on [dbo].[WebSiteLanguage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_WebSiteLanguage' AND object_id = OBJECT_ID(N'[dbo].[WebSiteLanguage]'))
ALTER TABLE [dbo].[WebSiteLanguage] ADD CONSTRAINT [PK_WebSiteLanguage] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_WebSiteLanguage_NaturalKey] on [dbo].[WebSiteLanguage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_WebSiteLanguage_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[WebSiteLanguage]'))
CREATE NONCLUSTERED INDEX [IX_WebSiteLanguage_NaturalKey] ON [dbo].[WebSiteLanguage] ([WebSiteId], [LanguageId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ContentItem]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ContentItem]', N'ContentItemId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ContentItem]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ContentItem].[ContentItemId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentItem] ALTER COLUMN [IsPage] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentItem] ALTER COLUMN [PublishOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentItem] ALTER COLUMN [ApprovedOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentItem] ALTER COLUMN [SubmittedForApprovalOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentItem] ALTER COLUMN [CreatedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ContentItem] on [dbo].[ContentItem]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ContentItem' AND object_id = OBJECT_ID(N'[dbo].[ContentItem]'))
ALTER TABLE [dbo].[ContentItem] ADD CONSTRAINT [PK_ContentItem] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ApplicationDictionary]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ApplicationDictionary]', N'ApplicationDictionaryId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ApplicationDictionary]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ApplicationDictionary].[ApplicationDictionaryId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ApplicationDictionary] ALTER COLUMN [IncludeInExport] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ApplicationDictionary] ALTER COLUMN [ExportWithChildren] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ApplicationDictionary] ALTER COLUMN [CanBeLocalized] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ApplicationDictionary] on [dbo].[ApplicationDictionary]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ApplicationDictionary' AND object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]'))
ALTER TABLE [dbo].[ApplicationDictionary] ADD CONSTRAINT [PK_ApplicationDictionary] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ApplicationDictionary_NaturalKey] on [dbo].[ApplicationDictionary]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ApplicationDictionary_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ApplicationDictionary_NaturalKey] ON [dbo].[ApplicationDictionary] ([ObjectName], [FieldName])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Document]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Document]', N'InternalUseOnly') IS NULL
ALTER TABLE [dbo].[Document] ADD[InternalUseOnly] [bit] NOT NULL CONSTRAINT [DF_Document_InternalUseOnly] DEFAULT ((0))
IF COL_LENGTH(N'[dbo].[Document]', N'LanguageId') IS NULL
ALTER TABLE [dbo].[Document] ADD[LanguageId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Document]', N'DocumentId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Document]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Document].[DocumentId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Document]', N'Created') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Document]', N'CreatedOn') IS NULL)
EXEC sp_rename N'[dbo].[Document].[Created]', N'CreatedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Document] ALTER COLUMN [Description] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Document] ALTER COLUMN [CreatedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Document] ALTER COLUMN [FilePath] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Document] ALTER COLUMN [FileName] [nvarchar] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Document] on [dbo].[Document]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Document' AND object_id = OBJECT_ID(N'[dbo].[Document]'))
ALTER TABLE [dbo].[Document] ADD CONSTRAINT [PK_Document] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[StyleTraitValue]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[StyleTraitValue]', N'StyleTraitValueId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[StyleTraitValue]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[StyleTraitValue].[StyleTraitValueId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[StyleTraitValue] ALTER COLUMN [IsDefault] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[StyleTraitValue] ALTER COLUMN [Description] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_StyleTraitValue] on [dbo].[StyleTraitValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_StyleTraitValue' AND object_id = OBJECT_ID(N'[dbo].[StyleTraitValue]'))
ALTER TABLE [dbo].[StyleTraitValue] ADD CONSTRAINT [PK_StyleTraitValue] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_StyleTraitValue_SortOrder] on [dbo].[StyleTraitValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_StyleTraitValue_SortOrder' AND object_id = OBJECT_ID(N'[dbo].[StyleTraitValue]'))
CREATE NONCLUSTERED INDEX [IX_StyleTraitValue_SortOrder] ON [dbo].[StyleTraitValue] ([StyleTraitId], [SortOrder])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_StyleTraitValue_NaturalKey] on [dbo].[StyleTraitValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_StyleTraitValue_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[StyleTraitValue]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_StyleTraitValue_NaturalKey] ON [dbo].[StyleTraitValue] ([StyleTraitId], [Value])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[RestrictionGroup]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[RestrictionGroup]', N'RestrictionGroupId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[RestrictionGroup]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[RestrictionGroup].[RestrictionGroupId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_RestrictionGroup] on [dbo].[RestrictionGroup]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_RestrictionGroup' AND object_id = OBJECT_ID(N'[dbo].[RestrictionGroup]'))
ALTER TABLE [dbo].[RestrictionGroup] ADD CONSTRAINT [PK_RestrictionGroup] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[RestrictionGroup]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_RestrictionGroup_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[RestrictionGroup]'))
ALTER TABLE [dbo].[RestrictionGroup] ADD CONSTRAINT [IX_RestrictionGroup_NaturalKey] UNIQUE NONCLUSTERED  ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Shipment]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Shipment]', N'ShipmentId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Shipment]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Shipment].[ShipmentId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Shipment]', N'EmailSent') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Shipment]', N'EmailSentDate') IS NULL)
EXEC sp_rename N'[dbo].[Shipment].[EmailSent]', N'EmailSentDate', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Shipment]', N'ASNSent') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Shipment]', N'ASNSentDate') IS NULL)
EXEC sp_rename N'[dbo].[Shipment].[ASNSent]', N'ASNSentDate', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Shipment] ALTER COLUMN [ShipmentDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Shipment] ALTER COLUMN [EmailSentDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Shipment] ALTER COLUMN [ASNSentDate] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Shipment] on [dbo].[Shipment]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Shipment' AND object_id = OBJECT_ID(N'[dbo].[Shipment]'))
ALTER TABLE [dbo].[Shipment] ADD CONSTRAINT [PK_Shipment] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Shipment_NaturalKey] on [dbo].[Shipment]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Shipment_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Shipment]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Shipment_NaturalKey] ON [dbo].[Shipment] ([ShipmentNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PunchOutSessionAccess]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutSessionAccess]', N'PunchOutSessionAccessId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutSessionAccess]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutSessionAccess].[PunchOutSessionAccessId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutSessionAccess]', N'CreateDate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutSessionAccess]', N'CreatedOn') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutSessionAccess].[CreateDate]', N'CreatedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutSessionAccess] ALTER COLUMN [CreatedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PunchOutSessionAccess] on [dbo].[PunchOutSessionAccess]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PunchOutSessionAccess' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSessionAccess]'))
ALTER TABLE [dbo].[PunchOutSessionAccess] ADD CONSTRAINT [PK_PunchOutSessionAccess] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[GlobalSynonym]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[GlobalSynonym]', N'LanguageId') IS NULL
ALTER TABLE [dbo].[GlobalSynonym] ADD[LanguageId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[GlobalSynonym]', N'GlobalSynonymId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[GlobalSynonym]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[GlobalSynonym].[GlobalSynonymId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_GlobalSynonym] on [dbo].[GlobalSynonym]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_GlobalSynonym' AND object_id = OBJECT_ID(N'[dbo].[GlobalSynonym]'))
ALTER TABLE [dbo].[GlobalSynonym] ADD CONSTRAINT [PK_GlobalSynonym] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_GlobalSynonym_NaturalKey] on [dbo].[GlobalSynonym]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_GlobalSynonym_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[GlobalSynonym]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_GlobalSynonym_NaturalKey] ON [dbo].[GlobalSynonym] ([SynonymType], [LanguageCode], [LookupValue])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Subscription]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Subscription]', N'SubscriptionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Subscription]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Subscription].[SubscriptionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Subscription]', N'Active') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Subscription]', N'ActivateOn') IS NULL)
EXEC sp_rename N'[dbo].[Subscription].[Active]', N'ActivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Subscription]', N'Deactivate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Subscription]', N'DeactivateOn') IS NULL)
EXEC sp_rename N'[dbo].[Subscription].[Deactivate]', N'DeactivateOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [ActivateOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [DeactivateOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [FixedPrice] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [IncludeInInitialOrder] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [AllMonths] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [January] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [February] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [March] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [April] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [May] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [June] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [July] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [August] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [September] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [October] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [November] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Subscription] ALTER COLUMN [December] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Subscription] on [dbo].[Subscription]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Subscription' AND object_id = OBJECT_ID(N'[dbo].[Subscription]'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [PK_Subscription] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Subscription_NaturalKey] on [dbo].[Subscription]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Subscription_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Subscription]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Subscription_NaturalKey] ON [dbo].[Subscription] ([CustomerOrderId], [ProductId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[HtmlRedirect]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[HtmlRedirect]', N'HtmlRedirectId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[HtmlRedirect]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[HtmlRedirect].[HtmlRedirectId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_HtmlRedirect] on [dbo].[HtmlRedirect]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_HtmlRedirect' AND object_id = OBJECT_ID(N'[dbo].[HtmlRedirect]'))
ALTER TABLE [dbo].[HtmlRedirect] ADD CONSTRAINT [PK_HtmlRedirect] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_HtmlRedirect_NaturalKey] on [dbo].[HtmlRedirect]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_HtmlRedirect_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[HtmlRedirect]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_HtmlRedirect_NaturalKey] ON [dbo].[HtmlRedirect] ([OldUrl])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[ProductRelatedProduct]'
GO
IF OBJECT_ID(N'[dbo].[ProductRelatedProduct]', 'U') IS NULL
CREATE TABLE [dbo].[ProductRelatedProduct]
(
[Id] [uniqueidentifier] NOT NULL CONSTRAINT [DF_ProductRelatedProduct_Id] DEFAULT (newsequentialid()),
[ProductId] [uniqueidentifier] NOT NULL,
[RelatedProductId] [uniqueidentifier] NOT NULL,
[ProductRelationshipMiscId] [uniqueidentifier] NOT NULL,
[SortOrder] [int] NOT NULL CONSTRAINT [DF_ProductRelatedProduct_SortOrder] DEFAULT ((0))
)
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ProductRelatedProduct] on [dbo].[ProductRelatedProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ProductRelatedProduct' AND object_id = OBJECT_ID(N'[dbo].[ProductRelatedProduct]'))
ALTER TABLE [dbo].[ProductRelatedProduct] ADD CONSTRAINT [PK_ProductRelatedProduct] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ProductRelatedProduct_NaturalKey] on [dbo].[ProductRelatedProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ProductRelatedProduct_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[ProductRelatedProduct]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ProductRelatedProduct_NaturalKey] ON [dbo].[ProductRelatedProduct] ([ProductId], [ProductRelationshipMiscId], [RelatedProductId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ProductRelatedProduct_RelatedProductProduct] on [dbo].[ProductRelatedProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ProductRelatedProduct_RelatedProductProduct' AND object_id = OBJECT_ID(N'[dbo].[ProductRelatedProduct]'))
CREATE NONCLUSTERED INDEX [IX_ProductRelatedProduct_RelatedProductProduct] ON [dbo].[ProductRelatedProduct] ([RelatedProductId], [ProductId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Message]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF COL_LENGTH(N'[dbo].[Message]', N'LanguageId') IS NULL
ALTER TABLE [dbo].[Message] ADD[LanguageId] [uniqueidentifier] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Message]', N'MessageId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Message]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Message].[MessageId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Message] ALTER COLUMN [DateToDisplay] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Message] ALTER COLUMN [DateToHide] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Message] on [dbo].[Message]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Message' AND object_id = OBJECT_ID(N'[dbo].[Message]'))
ALTER TABLE [dbo].[Message] ADD CONSTRAINT [PK_Message] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Message_DateToDisplay] on [dbo].[Message]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Message_DateToDisplay' AND object_id = OBJECT_ID(N'[dbo].[Message]'))
CREATE NONCLUSTERED INDEX [IX_Message_DateToDisplay] ON [dbo].[Message] ([DateToDisplay])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Message_NaturalKey] on [dbo].[Message]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Message_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Message]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Message_NaturalKey] ON [dbo].[Message] ([Subject], [DateToDisplay])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Rebuilding [dbo].[SeqBatchNumber]'
GO
CREATE TABLE [dbo].[RG_Recovery_1_SeqBatchNumber]
(
[Id] [int] NOT NULL IDENTITY(1, 1),
[Prefix] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_SeqBatchNumber_Prefix] DEFAULT ('')
)
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
SET IDENTITY_INSERT [dbo].[RG_Recovery_1_SeqBatchNumber] ON
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
INSERT INTO [dbo].[RG_Recovery_1_SeqBatchNumber]([Id], [Prefix]) SELECT [SeqBatchNumber], [Prefix] FROM [dbo].[SeqBatchNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
SET IDENTITY_INSERT [dbo].[RG_Recovery_1_SeqBatchNumber] OFF
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
DROP TABLE [dbo].[SeqBatchNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (OBJECT_ID(N'[dbo].[RG_Recovery_1_SeqBatchNumber]', 'U') IS NOT NULL) AND (OBJECT_ID(N'[dbo].[SeqBatchNumber]', 'U') IS NULL)
EXEC sp_rename N'[dbo].[RG_Recovery_1_SeqBatchNumber]', N'SeqBatchNumber', N'OBJECT'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_SeqBatchNumber] on [dbo].[SeqBatchNumber]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_SeqBatchNumber' AND object_id = OBJECT_ID(N'[dbo].[SeqBatchNumber]'))
ALTER TABLE [dbo].[SeqBatchNumber] ADD CONSTRAINT [PK_SeqBatchNumber] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ShipmentPackageLine]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShipmentPackageLine]', N'PackageLineId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShipmentPackageLine]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ShipmentPackageLine].[PackageLineId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ShipmentPackageLine] ALTER COLUMN [ProductDescription] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ShipmentPackageLine] on [dbo].[ShipmentPackageLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ShipmentPackageLine' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]'))
ALTER TABLE [dbo].[ShipmentPackageLine] ADD CONSTRAINT [PK_ShipmentPackageLine] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ShipmentPackageLine_OrderLineId] on [dbo].[ShipmentPackageLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ShipmentPackageLine_OrderLineId' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]'))
CREATE NONCLUSTERED INDEX [IX_ShipmentPackageLine_OrderLineId] ON [dbo].[ShipmentPackageLine] ([OrderLineId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ShipmentPackageLine_ShipmentPackageId] on [dbo].[ShipmentPackageLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ShipmentPackageLine_ShipmentPackageId' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]'))
CREATE NONCLUSTERED INDEX [IX_ShipmentPackageLine_ShipmentPackageId] ON [dbo].[ShipmentPackageLine] ([ShipmentPackageId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[PunchOutSetupRequest]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutSetupRequest]', N'PunchOutSetupRequestId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutSetupRequest]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutSetupRequest].[PunchOutSetupRequestId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[PunchOutSetupRequest]', N'CreateDate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[PunchOutSetupRequest]', N'CreatedOn') IS NULL)
EXEC sp_rename N'[dbo].[PunchOutSetupRequest].[CreateDate]', N'CreatedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[PunchOutSetupRequest] ALTER COLUMN [CreatedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_PunchOutSetupRequest] on [dbo].[PunchOutSetupRequest]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_PunchOutSetupRequest' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSetupRequest]'))
ALTER TABLE [dbo].[PunchOutSetupRequest] ADD CONSTRAINT [PK_PunchOutSetupRequest] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ContentItemField]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ContentItemField]', N'ContentItemFieldId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ContentItemField]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ContentItemField].[ContentItemFieldId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentItemField] ALTER COLUMN [DateTimeValue] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentItemField] ALTER COLUMN [DecimalValue] [decimal] (18, 5) NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentItemField] ALTER COLUMN [PublishOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentItemField] ALTER COLUMN [ApprovedOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentItemField] ALTER COLUMN [SubmittedForApprovalOn] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ContentItemField] ALTER COLUMN [CreatedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ContentItemField] on [dbo].[ContentItemField]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ContentItemField' AND object_id = OBJECT_ID(N'[dbo].[ContentItemField]'))
ALTER TABLE [dbo].[ContentItemField] ADD CONSTRAINT [PK_ContentItemField] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ContentItemField_ContentKeyPublishOn] on [dbo].[ContentItemField]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ContentItemField_ContentKeyPublishOn' AND object_id = OBJECT_ID(N'[dbo].[ContentItemField]'))
CREATE NONCLUSTERED INDEX [IX_ContentItemField_ContentKeyPublishOn] ON [dbo].[ContentItemField] ([ContentKey], [PublishOn])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CarrierZone]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CarrierZone]', N'CarrierZoneId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CarrierZone]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CarrierZone].[CarrierZoneId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CarrierZone] on [dbo].[CarrierZone]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CarrierZone' AND object_id = OBJECT_ID(N'[dbo].[CarrierZone]'))
ALTER TABLE [dbo].[CarrierZone] ADD CONSTRAINT [PK_CarrierZone] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CarrierZone_NaturalKey] on [dbo].[CarrierZone]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CarrierZone_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CarrierZone]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CarrierZone_NaturalKey] ON [dbo].[CarrierZone] ([CarrierId], [Zone])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[JobDefinition]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[JobDefinition]', N'IntegrationJobDefinitionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[JobDefinition]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[JobDefinition].[IntegrationJobDefinitionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [Description] [nvarchar] (2048) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [DebuggingEnabled] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [PassThroughJob] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [PassDataSetToLinkedJob] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [UseDeltaDataSet] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [LastRunDateTime] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [RecurringJob] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [RecurringStartDateTime] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [RecurringEndDateTime] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [RecurringStartTime] [datetime2] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [RunStepsInParallel] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[JobDefinition] ALTER COLUMN [LinkedJobCondition] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_JobDefinition] on [dbo].[JobDefinition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_JobDefinition' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [PK_JobDefinition] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_JobDefinition_NaturalKey] on [dbo].[JobDefinition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_JobDefinition_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_JobDefinition_NaturalKey] ON [dbo].[JobDefinition] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CarrierZoneRate]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CarrierZoneRate]', N'CarrierZoneRateId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CarrierZoneRate]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CarrierZoneRate].[CarrierZoneRateId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CarrierZoneRate] on [dbo].[CarrierZoneRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CarrierZoneRate' AND object_id = OBJECT_ID(N'[dbo].[CarrierZoneRate]'))
ALTER TABLE [dbo].[CarrierZoneRate] ADD CONSTRAINT [PK_CarrierZoneRate] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CarrierZoneRate_NaturalKey] on [dbo].[CarrierZoneRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CarrierZoneRate_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CarrierZoneRate]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CarrierZoneRate_NaturalKey] ON [dbo].[CarrierZoneRate] ([CarrierZoneId], [Weight])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ShipmentPackage]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShipmentPackage]', N'ShipmentPackageId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShipmentPackage]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ShipmentPackage].[ShipmentPackageId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ShipmentPackage] on [dbo].[ShipmentPackage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ShipmentPackage' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackage]'))
ALTER TABLE [dbo].[ShipmentPackage] ADD CONSTRAINT [PK_ShipmentPackage] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ShipmentPackage_NaturalKey] on [dbo].[ShipmentPackage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ShipmentPackage_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackage]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ShipmentPackage_NaturalKey] ON [dbo].[ShipmentPackage] ([ShipmentId], [PackageNumber])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CarrierZonePostalCodeRange]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CarrierZonePostalCodeRange]', N'CarrierZoneZipCodeRangeId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CarrierZonePostalCodeRange]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CarrierZonePostalCodeRange].[CarrierZoneZipCodeRangeId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CarrierZonePostalCodeRange]', N'ZipStartRange') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CarrierZonePostalCodeRange]', N'PostalCodeStartRange') IS NULL)
EXEC sp_rename N'[dbo].[CarrierZonePostalCodeRange].[ZipStartRange]', N'PostalCodeStartRange', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CarrierZonePostalCodeRange]', N'ZipEndRange') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CarrierZonePostalCodeRange]', N'PostalCodeEndRange') IS NULL)
EXEC sp_rename N'[dbo].[CarrierZonePostalCodeRange].[ZipEndRange]', N'PostalCodeEndRange', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CarrierZonePostalCodeRange] on [dbo].[CarrierZonePostalCodeRange]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CarrierZonePostalCodeRange' AND object_id = OBJECT_ID(N'[dbo].[CarrierZonePostalCodeRange]'))
ALTER TABLE [dbo].[CarrierZonePostalCodeRange] ADD CONSTRAINT [PK_CarrierZonePostalCodeRange] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CarrierZonePostalCodeRange_NaturalKey] on [dbo].[CarrierZonePostalCodeRange]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CarrierZonePostalCodeRange_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CarrierZonePostalCodeRange]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_CarrierZonePostalCodeRange_NaturalKey] ON [dbo].[CarrierZonePostalCodeRange] ([CarrierZoneId], [PostalCodeStartRange])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Configuration]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Configuration]', N'ConfigurationId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Configuration]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Configuration].[ConfigurationId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Configuration] ALTER COLUMN [HasSmartPart] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Configuration] ALTER COLUMN [OverrideOnRefresh] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Configuration] ALTER COLUMN [DisplaySummary] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Configuration] on [dbo].[Configuration]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Configuration' AND object_id = OBJECT_ID(N'[dbo].[Configuration]'))
ALTER TABLE [dbo].[Configuration] ADD CONSTRAINT [PK_Configuration] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Configuration_NaturalKey] on [dbo].[Configuration]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Configuration_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Configuration]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Configuration_NaturalKey] ON [dbo].[Configuration] ([Name], [Revision])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[CategoryRelatedProduct]'
GO
IF OBJECT_ID(N'[dbo].[CategoryRelatedProduct]', 'U') IS NULL
CREATE TABLE [dbo].[CategoryRelatedProduct]
(
[Id] [uniqueidentifier] NOT NULL CONSTRAINT [DF_CategoryRelatedProduct_Id] DEFAULT (newsequentialid()),
[CategoryId] [uniqueidentifier] NOT NULL,
[ProductRelationshipMiscId] [uniqueidentifier] NOT NULL,
[ProductId] [uniqueidentifier] NOT NULL,
[SortOrder] [int] NOT NULL CONSTRAINT [DF_CategoryRelatedProduct_SortOrder] DEFAULT ((0))
)
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CategoryRelatedProduct] on [dbo].[CategoryRelatedProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CategoryRelatedProduct' AND object_id = OBJECT_ID(N'[dbo].[CategoryRelatedProduct]'))
ALTER TABLE [dbo].[CategoryRelatedProduct] ADD CONSTRAINT [PK_CategoryRelatedProduct] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_CategoryRelatedProduct_NaturalKey] on [dbo].[CategoryRelatedProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_CategoryRelatedProduct_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[CategoryRelatedProduct]'))
CREATE NONCLUSTERED INDEX [IX_CategoryRelatedProduct_NaturalKey] ON [dbo].[CategoryRelatedProduct] ([CategoryId], [ProductRelationshipMiscId], [ProductId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[MessageAudit]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[MessageAudit]', N'MessageAuditId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[MessageAudit]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[MessageAudit].[MessageAuditId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[MessageAudit]', N'CreatedDate') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[MessageAudit]', N'CreatedOn') IS NULL)
EXEC sp_rename N'[dbo].[MessageAudit].[CreatedDate]', N'CreatedOn', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[MessageAudit] ALTER COLUMN [CreatedOn] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_MessageAudit] on [dbo].[MessageAudit]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_MessageAudit' AND object_id = OBJECT_ID(N'[dbo].[MessageAudit]'))
ALTER TABLE [dbo].[MessageAudit] ADD CONSTRAINT [PK_MessageAudit] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_MessageAudit_MessageId] on [dbo].[MessageAudit]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_MessageAudit_MessageId' AND object_id = OBJECT_ID(N'[dbo].[MessageAudit]'))
CREATE NONCLUSTERED INDEX [IX_MessageAudit_MessageId] ON [dbo].[MessageAudit] ([MessageId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CreditCardTransaction]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CreditCardTransaction]', N'CreditCardTransactionId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CreditCardTransaction]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[CreditCardTransaction].[CreditCardTransactionId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CreditCardTransaction] ALTER COLUMN [TransactionDate] [datetime2] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CreditCardTransaction] ALTER COLUMN [Amount] [decimal] (18, 5) NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[CreditCardTransaction] ALTER COLUMN [PostedToERP] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CreditCardTransaction] on [dbo].[CreditCardTransaction]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CreditCardTransaction' AND object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]'))
ALTER TABLE [dbo].[CreditCardTransaction] ADD CONSTRAINT [PK_CreditCardTransaction] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[Affiliate]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Affiliate]', N'AffiliateId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Affiliate]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[Affiliate].[AffiliateId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[Affiliate]', N'Image') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[Affiliate]', N'ImagePath') IS NULL)
EXEC sp_rename N'[dbo].[Affiliate].[Image]', N'ImagePath', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Affiliate] ALTER COLUMN [ImagePath] [nvarchar] (512) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Affiliate] ALTER COLUMN [IsActive] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Affiliate] ALTER COLUMN [Description] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Affiliate] ALTER COLUMN [Url] [nvarchar] (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[Affiliate] ALTER COLUMN [ReplaceLogoImage] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_Affiliate] on [dbo].[Affiliate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_Affiliate' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]'))
ALTER TABLE [dbo].[Affiliate] ADD CONSTRAINT [PK_Affiliate] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_Affiliate_NaturalKey] on [dbo].[Affiliate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_Affiliate_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_Affiliate_NaturalKey] ON [dbo].[Affiliate] ([Name])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ShipRate]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ShipRate]', N'ShipRateId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ShipRate]', N'Id') IS NULL)
EXEC sp_rename N'[dbo].[ShipRate].[ShipRateId]', N'Id', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[ShipRate] ALTER COLUMN [PerEach] [bit] NOT NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ShipRate] on [dbo].[ShipRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ShipRate' AND object_id = OBJECT_ID(N'[dbo].[ShipRate]'))
ALTER TABLE [dbo].[ShipRate] ADD CONSTRAINT [PK_ShipRate] PRIMARY KEY CLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_ShipRate_NaturalKey] on [dbo].[ShipRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_ShipRate_NaturalKey' AND object_id = OBJECT_ID(N'[dbo].[ShipRate]'))
CREATE UNIQUE NONCLUSTERED INDEX [IX_ShipRate_NaturalKey] ON [dbo].[ShipRate] ([ShipViaId], [OrderAmount])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[CategoryAttributeValue]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[CategoryAttributeValue]', N'FilterValueId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[CategoryAttributeValue]', N'AttributeValueId') IS NULL)
EXEC sp_rename N'[dbo].[CategoryAttributeValue].[FilterValueId]', N'AttributeValueId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_CategoryAttributeValue] on [dbo].[CategoryAttributeValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_CategoryAttributeValue' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeValue]'))
ALTER TABLE [dbo].[CategoryAttributeValue] ADD CONSTRAINT [PK_CategoryAttributeValue] PRIMARY KEY CLUSTERED  ([CategoryId], [AttributeValueId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[ProductAttributeValue]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF (COL_LENGTH(N'[dbo].[ProductAttributeValue]', N'FilterValueId') IS NOT NULL) AND (COL_LENGTH(N'[dbo].[ProductAttributeValue]', N'AttributeValueId') IS NULL)
EXEC sp_rename N'[dbo].[ProductAttributeValue].[FilterValueId]', N'AttributeValueId', N'COLUMN'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_ProductAttributeValue] on [dbo].[ProductAttributeValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_ProductAttributeValue' AND object_id = OBJECT_ID(N'[dbo].[ProductAttributeValue]'))
ALTER TABLE [dbo].[ProductAttributeValue] ADD CONSTRAINT [PK_ProductAttributeValue] PRIMARY KEY CLUSTERED  ([ProductId], [AttributeValueId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_WarehouseAlternate] on [dbo].[WarehouseAlternate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK_WarehouseAlternate' AND object_id = OBJECT_ID(N'[dbo].[WarehouseAlternate]'))
ALTER TABLE [dbo].[WarehouseAlternate] ADD CONSTRAINT [PK_WarehouseAlternate] PRIMARY KEY CLUSTERED  ([WarehouseId], [AlternateWarehouseId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating index [IX_MenuRole] on [dbo].[MenuRole]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'IX_MenuRole' AND object_id = OBJECT_ID(N'[dbo].[MenuRole]'))
CREATE NONCLUSTERED INDEX [IX_MenuRole] ON [dbo].[MenuRole] ([MenuId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK__aspnet_Applicati__2645B050] on [dbo].[aspnet_Applications]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK__aspnet_Applicati__2645B050' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Applications]'))
ALTER TABLE [dbo].[aspnet_Applications] ADD CONSTRAINT [PK__aspnet_Applicati__2645B050] PRIMARY KEY NONCLUSTERED  ([ApplicationId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK__aspnet_Paths__6CD828CA] on [dbo].[aspnet_Paths]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK__aspnet_Paths__6CD828CA' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Paths]'))
ALTER TABLE [dbo].[aspnet_Paths] ADD CONSTRAINT [PK__aspnet_Paths__6CD828CA] PRIMARY KEY NONCLUSTERED  ([PathId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK__aspnet_Personali__756D6ECB] on [dbo].[aspnet_PersonalizationPerUser]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK__aspnet_Personali__756D6ECB' AND object_id = OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser]'))
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] ADD CONSTRAINT [PK__aspnet_Personali__756D6ECB] PRIMARY KEY NONCLUSTERED  ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK__aspnet_Roles__59C55456] on [dbo].[aspnet_Roles]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK__aspnet_Roles__59C55456' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Roles]'))
ALTER TABLE [dbo].[aspnet_Roles] ADD CONSTRAINT [PK__aspnet_Roles__59C55456] PRIMARY KEY NONCLUSTERED  ([RoleId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK__aspnet_Users__2B0A656D] on [dbo].[aspnet_Users]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE name = N'PK__aspnet_Users__2B0A656D' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Users]'))
ALTER TABLE [dbo].[aspnet_Users] ADD CONSTRAINT [PK__aspnet_Users__2B0A656D] PRIMARY KEY NONCLUSTERED  ([UserId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[AttributeType]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_AttributeType_Name]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U'))
ALTER TABLE [dbo].[AttributeType] WITH NOCHECK ADD CONSTRAINT [CK_AttributeType_Name] CHECK ((len([Name])>(0)))
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[LocalTaxRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_LocalTaxRate_PostalCode]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[LocalTaxRate]', 'U'))
ALTER TABLE [dbo].[LocalTaxRate] WITH NOCHECK ADD CONSTRAINT [CK_LocalTaxRate_PostalCode] CHECK ((len([PostalCode])>(0)))
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[PaymentMethod]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_PaymentMethod_Name]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U'))
ALTER TABLE [dbo].[PaymentMethod] WITH NOCHECK ADD CONSTRAINT [CK_PaymentMethod_Name] CHECK ((len([Name])>(0)))
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Salesperson]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_Salesperson_SalespersonNumber]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U'))
ALTER TABLE [dbo].[Salesperson] WITH NOCHECK ADD CONSTRAINT [CK_Salesperson_SalespersonNumber] CHECK ((len([SalespersonNumber])>(0)))
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[WishList]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_WishList_Name]', 'C') AND parent_object_id = OBJECT_ID(N'[dbo].[WishList]', 'U'))
ALTER TABLE [dbo].[WishList] WITH NOCHECK ADD CONSTRAINT [CK_WishList_Name] CHECK ((len([Name])>(0)))
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Affiliate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_Id]', 'D'))
ALTER TABLE [dbo].[Affiliate] ADD CONSTRAINT [DF_Affiliate_Id] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ImagePath' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_ImagePath]', 'D'))
ALTER TABLE [dbo].[Affiliate] ADD CONSTRAINT [DF_Affiliate_ImagePath] DEFAULT ('') FOR [ImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_IsActive]', 'D'))
ALTER TABLE [dbo].[Affiliate] ADD CONSTRAINT [DF_Affiliate_IsActive] DEFAULT ((0)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_Description]', 'D'))
ALTER TABLE [dbo].[Affiliate] ADD CONSTRAINT [DF_Affiliate_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Url' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_Url]', 'D'))
ALTER TABLE [dbo].[Affiliate] ADD CONSTRAINT [DF_Affiliate_Url] DEFAULT ('') FOR [Url]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ReplaceLogoImage' AND object_id = OBJECT_ID(N'[dbo].[Affiliate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Affiliate_ReplaceLogoImage]', 'D'))
ALTER TABLE [dbo].[Affiliate] ADD CONSTRAINT [DF_Affiliate_ReplaceLogoImage] DEFAULT ((0)) FOR [ReplaceLogoImage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ApplicationDictionary]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationDictionary_Id]', 'D'))
ALTER TABLE [dbo].[ApplicationDictionary] ADD CONSTRAINT [DF_ApplicationDictionary_Id] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IncludeInExport' AND object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationDictionary_IncludeInExport]', 'D'))
ALTER TABLE [dbo].[ApplicationDictionary] ADD CONSTRAINT [DF_ApplicationDictionary_IncludeInExport] DEFAULT ((0)) FOR [IncludeInExport]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ExportWithChildren' AND object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationDictionary_ExportWithChildren]', 'D'))
ALTER TABLE [dbo].[ApplicationDictionary] ADD CONSTRAINT [DF_ApplicationDictionary_ExportWithChildren] DEFAULT ((0)) FOR [ExportWithChildren]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CanBeLocalized' AND object_id = OBJECT_ID(N'[dbo].[ApplicationDictionary]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationDictionary_CanBeLocalized]', 'D'))
ALTER TABLE [dbo].[ApplicationDictionary] ADD CONSTRAINT [DF_ApplicationDictionary_CanBeLocalized] DEFAULT ((0)) FOR [CanBeLocalized]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ApplicationLog]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Message' AND object_id = OBJECT_ID(N'[dbo].[ApplicationLog]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationLog_Message]', 'D'))
ALTER TABLE [dbo].[ApplicationLog] ADD CONSTRAINT [DF_ApplicationLog_Message] DEFAULT ('') FOR [Message]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LogDate' AND object_id = OBJECT_ID(N'[dbo].[ApplicationLog]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationLog_LogDate]', 'D'))
ALTER TABLE [dbo].[ApplicationLog] ADD CONSTRAINT [DF_ApplicationLog_LogDate] DEFAULT (getdate()) FOR [LogDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ApplicationSetting]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[ApplicationSetting]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationSetting_Id]', 'D'))
ALTER TABLE [dbo].[ApplicationSetting] ADD CONSTRAINT [DF_ApplicationSetting_Id] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Value' AND object_id = OBJECT_ID(N'[dbo].[ApplicationSetting]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationSetting_Value]', 'D'))
ALTER TABLE [dbo].[ApplicationSetting] ADD CONSTRAINT [DF_ApplicationSetting_Value] DEFAULT ('') FOR [Value]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[ApplicationSetting]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ApplicationSetting_Description]', 'D'))
ALTER TABLE [dbo].[ApplicationSetting] ADD CONSTRAINT [DF_ApplicationSetting_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[AttributeType]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_AttributeType_Id]', 'D'))
ALTER TABLE [dbo].[AttributeType] ADD CONSTRAINT [DF_AttributeType_Id] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_AttributeType_Name]', 'D'))
ALTER TABLE [dbo].[AttributeType] ADD CONSTRAINT [DF_AttributeType_Name] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_AttributeType_IsActive]', 'D'))
ALTER TABLE [dbo].[AttributeType] ADD CONSTRAINT [DF_AttributeType_IsActive] DEFAULT ((1)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Label' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_AttributeType_Label]', 'D'))
ALTER TABLE [dbo].[AttributeType] ADD CONSTRAINT [DF_AttributeType_Label] DEFAULT ('') FOR [Label]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsFilter' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_AttributeType_IsFilter]', 'D'))
ALTER TABLE [dbo].[AttributeType] ADD CONSTRAINT [DF_AttributeType_IsFilter] DEFAULT ((1)) FOR [IsFilter]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsComparable' AND object_id = OBJECT_ID(N'[dbo].[AttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_AttributeType_IsComparable]', 'D'))
ALTER TABLE [dbo].[AttributeType] ADD CONSTRAINT [DF_AttributeType_IsComparable] DEFAULT ((0)) FOR [IsComparable]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[AttributeValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[AttributeValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_AttributeValue_FilterValueId]', 'D'))
ALTER TABLE [dbo].[AttributeValue] ADD CONSTRAINT [DF_AttributeValue_FilterValueId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Value' AND object_id = OBJECT_ID(N'[dbo].[AttributeValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_AttributeValue_Value]', 'D'))
ALTER TABLE [dbo].[AttributeValue] ADD CONSTRAINT [DF_AttributeValue_Value] DEFAULT ('') FOR [Value]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SortOrder' AND object_id = OBJECT_ID(N'[dbo].[AttributeValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_AttributeValue_SortOrder]', 'D'))
ALTER TABLE [dbo].[AttributeValue] ADD CONSTRAINT [DF_AttributeValue_SortOrder] DEFAULT ((0)) FOR [SortOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[AttributeValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_AttributeValue_IsActive]', 'D'))
ALTER TABLE [dbo].[AttributeValue] ADD CONSTRAINT [DF_AttributeValue_IsActive] DEFAULT ((1)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CarrierPackage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[CarrierPackage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CarrierPackage_IsActive]', 'D'))
ALTER TABLE [dbo].[CarrierPackage] ADD CONSTRAINT [DF_CarrierPackage_IsActive] DEFAULT ((1)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CarrierZonePostalCodeRange]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[CarrierZonePostalCodeRange]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CarrierZonePostalCodeRange_CarrierZonePostalCodeRangeId]', 'D'))
ALTER TABLE [dbo].[CarrierZonePostalCodeRange] ADD CONSTRAINT [DF_CarrierZonePostalCodeRange_CarrierZonePostalCodeRangeId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PostalCodeStartRange' AND object_id = OBJECT_ID(N'[dbo].[CarrierZonePostalCodeRange]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CarrierZonePostalCodeRange_PostalStartRange]', 'D'))
ALTER TABLE [dbo].[CarrierZonePostalCodeRange] ADD CONSTRAINT [DF_CarrierZonePostalCodeRange_PostalStartRange] DEFAULT ('') FOR [PostalCodeStartRange]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PostalCodeEndRange' AND object_id = OBJECT_ID(N'[dbo].[CarrierZonePostalCodeRange]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CarrierZonePostalCodeRange_PostalEndRange]', 'D'))
ALTER TABLE [dbo].[CarrierZonePostalCodeRange] ADD CONSTRAINT [DF_CarrierZonePostalCodeRange_PostalEndRange] DEFAULT ('') FOR [PostalCodeEndRange]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Carrier]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_Description]', 'D'))
ALTER TABLE [dbo].[Carrier] ADD CONSTRAINT [DF_Carrier_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ImagePath' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_Image]', 'D'))
ALTER TABLE [dbo].[Carrier] ADD CONSTRAINT [DF_Carrier_Image] DEFAULT ('') FOR [ImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AccessKey' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_AccessKey]', 'D'))
ALTER TABLE [dbo].[Carrier] ADD CONSTRAINT [DF_Carrier_AccessKey] DEFAULT ('') FOR [AccessKey]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Enable' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_Enable]', 'D'))
ALTER TABLE [dbo].[Carrier] ADD CONSTRAINT [DF_Carrier_Enable] DEFAULT ((0)) FOR [Enable]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsLive' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_IsLive]', 'D'))
ALTER TABLE [dbo].[Carrier] ADD CONSTRAINT [DF_Carrier_IsLive] DEFAULT ((0)) FOR [IsLive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LiveUrl' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_LiveUrl]', 'D'))
ALTER TABLE [dbo].[Carrier] ADD CONSTRAINT [DF_Carrier_LiveUrl] DEFAULT ('') FOR [LiveUrl]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TestUrl' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_TestUrl]', 'D'))
ALTER TABLE [dbo].[Carrier] ADD CONSTRAINT [DF_Carrier_TestUrl] DEFAULT ('') FOR [TestUrl]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPrimaryCarrier' AND object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Carrier_IsPrimaryCarrier]', 'D'))
ALTER TABLE [dbo].[Carrier] ADD CONSTRAINT [DF_Carrier_IsPrimaryCarrier] DEFAULT ((0)) FOR [IsPrimaryCarrier]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CategoryAttributeType]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CategoryAttributeType_CategoryAttributeTypeId]', 'D'))
ALTER TABLE [dbo].[CategoryAttributeType] ADD CONSTRAINT [DF_CategoryAttributeType_CategoryAttributeTypeId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SortOrder' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CategoryAttributeType_SortOrder]', 'D'))
ALTER TABLE [dbo].[CategoryAttributeType] ADD CONSTRAINT [DF_CategoryAttributeType_SortOrder] DEFAULT ((0)) FOR [SortOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CategoryAttributeType_IsActive]', 'D'))
ALTER TABLE [dbo].[CategoryAttributeType] ADD CONSTRAINT [DF_CategoryAttributeType_IsActive] DEFAULT ((1)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DetailDisplaySequence' AND object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CategoryAttributeType_DetailDisplaySequence]', 'D'))
ALTER TABLE [dbo].[CategoryAttributeType] ADD CONSTRAINT [DF_CategoryAttributeType_DetailDisplaySequence] DEFAULT (NULL) FOR [DetailDisplaySequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Category]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SmallImagePath' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_SmallImagePath]', 'D'))
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [DF_Category_SmallImagePath] DEFAULT ('') FOR [SmallImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LargeImagePath' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_LargeImagePath]', 'D'))
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [DF_Category_LargeImagePath] DEFAULT ('') FOR [LargeImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ActivateOn' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_Active]', 'D'))
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [DF_Category_Active] DEFAULT (getdate()) FOR [ActivateOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PageTitle' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_PageTitle]', 'D'))
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [DF_Category_PageTitle] DEFAULT ('') FOR [PageTitle]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsFeatured' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__Category__IsFeat__33408412]', 'D'))
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [DF__Category__IsFeat__33408412] DEFAULT ((0)) FOR [IsFeatured]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDynamic' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_IsDynamic]', 'D'))
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [DF_Category_IsDynamic] DEFAULT ((0)) FOR [IsDynamic]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ImageAltText' AND object_id = OBJECT_ID(N'[dbo].[Category]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Category_AltText]', 'D'))
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [DF_Category_AltText] DEFAULT ('') FOR [ImageAltText]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Company]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LogoImagePath' AND object_id = OBJECT_ID(N'[dbo].[Company]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Company_Image]', 'D'))
ALTER TABLE [dbo].[Company] ADD CONSTRAINT [DF_Company_Image] DEFAULT ('') FOR [LogoImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ReplaceLogoImage' AND object_id = OBJECT_ID(N'[dbo].[Company]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Company_ReplaceImage]', 'D'))
ALTER TABLE [dbo].[Company] ADD CONSTRAINT [DF_Company_ReplaceImage] DEFAULT ((0)) FOR [ReplaceLogoImage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ConfigurationConditionFilter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Condition' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationConditionFilter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationConditionFilter_Condition]', 'D'))
ALTER TABLE [dbo].[ConfigurationConditionFilter] ADD CONSTRAINT [DF_ConfigurationConditionFilter_Condition] DEFAULT ('') FOR [Condition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FilterValue' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationConditionFilter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationConditionFilter_FilterValue]', 'D'))
ALTER TABLE [dbo].[ConfigurationConditionFilter] ADD CONSTRAINT [DF_ConfigurationConditionFilter_FilterValue] DEFAULT ('') FOR [FilterValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ConfigurationOptionCondition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Sequence' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOptionCondition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOptionCondition_Sequence]', 'D'))
ALTER TABLE [dbo].[ConfigurationOptionCondition] ADD CONSTRAINT [DF_ConfigurationOptionCondition_Sequence] DEFAULT ((0)) FOR [Sequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ScriptCondition' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOptionCondition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOptionCondition_ScriptCondition_1]', 'D'))
ALTER TABLE [dbo].[ConfigurationOptionCondition] ADD CONSTRAINT [DF_ConfigurationOptionCondition_ScriptCondition_1] DEFAULT ('') FOR [ScriptCondition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QueryName' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOptionCondition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOptionCondition_QueryName]', 'D'))
ALTER TABLE [dbo].[ConfigurationOptionCondition] ADD CONSTRAINT [DF_ConfigurationOptionCondition_QueryName] DEFAULT ('') FOR [QueryName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ConfigurationOption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_Name]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_Name] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_Description]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Sequence' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_Sequence]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_Sequence] DEFAULT ((0)) FOR [Sequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Type' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_Type]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_Type] DEFAULT ('') FOR [Type]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsVisible' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_IsVisible]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_IsVisible] DEFAULT ((0)) FOR [IsVisible]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsRequired' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_IsRequired]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_IsRequired] DEFAULT ((0)) FOR [IsRequired]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SetAsFutureDefault' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_SetAsFutureDefault]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_SetAsFutureDefault] DEFAULT ((0)) FOR [SetAsFutureDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'XPosition' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_XPosition]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_XPosition] DEFAULT ((0)) FOR [XPosition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'YPosition' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_YPosition]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_YPosition] DEFAULT ((0)) FOR [YPosition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Height' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_Height]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_Height] DEFAULT ((0)) FOR [Height]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Width' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_Width]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_Width] DEFAULT ((0)) FOR [Width]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LabelValue' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_LabelValue]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_LabelValue] DEFAULT ('') FOR [LabelValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IncludeInLineDescription' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_IncludeInLineDescription]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_IncludeInLineDescription] DEFAULT ((0)) FOR [IncludeInLineDescription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ToolTip' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ToolTip]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ToolTip] DEFAULT ('') FOR [ToolTip]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DefaultValue' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_DefaultValue]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_DefaultValue] DEFAULT ('') FOR [DefaultValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TextMinLength' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_TextMinLength]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_TextMinLength] DEFAULT ((0)) FOR [TextMinLength]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TextMaxLength' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_TextMaxLength]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_TextMaxLength] DEFAULT ((0)) FOR [TextMaxLength]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TextCharacterType' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_TextCharacterType]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_TextCharacterType] DEFAULT ('') FOR [TextCharacterType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TextIsMultiline' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_TextIsMultiline]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_TextIsMultiline] DEFAULT ((0)) FOR [TextIsMultiline]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TextValidEntryList' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_TextValidEntryList]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_TextValidEntryList] DEFAULT ('') FOR [TextValidEntryList]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'NumberMinValue' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_NumberMinValue]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_NumberMinValue] DEFAULT ((0)) FOR [NumberMinValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'NumberMaxValue' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_NumberMaxValue]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_NumberMaxValue] DEFAULT ((0)) FOR [NumberMaxValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'NumberDecimals' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_NumberDecimals]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_NumberDecimals] DEFAULT ((0)) FOR [NumberDecimals]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DateCheckRange' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_DateCheckRange]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_DateCheckRange] DEFAULT ((0)) FOR [DateCheckRange]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DateMaxDaysBack' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_DateMaxDaysBack]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_DateMaxDaysBack] DEFAULT ((0)) FOR [DateMaxDaysBack]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DateMaxDaysForward' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_DateMaxDaysForward]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_DateMaxDaysForward] DEFAULT ((0)) FOR [DateMaxDaysForward]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ContainerFileType' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ContainerFileType]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ContainerFileType] DEFAULT ('') FOR [ContainerFileType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ContainerFileLocation' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ContainerFileLocation]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ContainerFileLocation] DEFAULT ('') FOR [ContainerFileLocation]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RadioButtonOrientation' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_RadioButtonOrientation]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_RadioButtonOrientation] DEFAULT ('') FOR [RadioButtonOrientation]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ComboConditionalList' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ComboConditionalList]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ComboConditionalList] DEFAULT ((0)) FOR [ComboConditionalList]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ComboMultiSelect' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ComboMultiSelect]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ComboMultiSelect] DEFAULT ((0)) FOR [ComboMultiSelect]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ComboIsProduct' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ComboIsProduct]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ComboIsProduct] DEFAULT ((0)) FOR [ComboIsProduct]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ComboProductSeparateLine' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ComboProductSeparateLine]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ComboProductSeparateLine] DEFAULT ((0)) FOR [ComboProductSeparateLine]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ComboProductDescription' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ComboProductDescription]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ComboProductDescription] DEFAULT ('') FOR [ComboProductDescription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ComboProductPriceSeparately' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ComboProductPriceSeparately]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ComboProductPriceSeparately] DEFAULT ((0)) FOR [ComboProductPriceSeparately]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SelectionListDisplays' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_SelectionListDisplays]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_SelectionListDisplays] DEFAULT ('') FOR [SelectionListDisplays]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SelectionListValues' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_SelectionListValues]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_SelectionListValues] DEFAULT ('') FOR [SelectionListValues]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SelectionListPriceAdjustment' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_SelectionListPriceAdjustment]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_SelectionListPriceAdjustment] DEFAULT ('') FOR [SelectionListPriceAdjustment]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubconfigurationPartNumber' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_SubconfigurationPartNumber]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_SubconfigurationPartNumber] DEFAULT ('') FOR [SubconfigurationPartNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SmartPartSegment' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_SmartPartSegment]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_SmartPartSegment] DEFAULT ('') FOR [SmartPartSegment]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SmartPartLength' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_SmartPartLength]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_SmartPartLength] DEFAULT ((0)) FOR [SmartPartLength]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ScriptPromptWhen' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ScriptPromptWhen]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ScriptPromptWhen] DEFAULT ('') FOR [ScriptPromptWhen]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ScriptOnEntry' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ScriptOnEntry]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ScriptOnEntry] DEFAULT ('') FOR [ScriptOnEntry]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ScriptOnLeave' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationOption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationOption_ScriptOnLeave]', 'D'))
ALTER TABLE [dbo].[ConfigurationOption] ADD CONSTRAINT [DF_ConfigurationOption_ScriptOnLeave] DEFAULT ('') FOR [ScriptOnLeave]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ConfigurationPage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SkipIfNoInputs' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationPage_SkipIfNoInputs]', 'D'))
ALTER TABLE [dbo].[ConfigurationPage] ADD CONSTRAINT [DF_ConfigurationPage_SkipIfNoInputs] DEFAULT ((1)) FOR [SkipIfNoInputs]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SkipScriptsIfNoInputs' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationPage_SkipScriptsIfNoInputs]', 'D'))
ALTER TABLE [dbo].[ConfigurationPage] ADD CONSTRAINT [DF_ConfigurationPage_SkipScriptsIfNoInputs] DEFAULT ((1)) FOR [SkipScriptsIfNoInputs]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HtmlOutput' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationPage_HtmlOutput]', 'D'))
ALTER TABLE [dbo].[ConfigurationPage] ADD CONSTRAINT [DF_ConfigurationPage_HtmlOutput] DEFAULT ('') FOR [HtmlOutput]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OverrideHtmlOutput' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationPage_OverrideHtmlOutput]', 'D'))
ALTER TABLE [dbo].[ConfigurationPage] ADD CONSTRAINT [DF_ConfigurationPage_OverrideHtmlOutput] DEFAULT ((0)) FOR [OverrideHtmlOutput]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OverrideCssOutput' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationPage_OverrideCssOutput]', 'D'))
ALTER TABLE [dbo].[ConfigurationPage] ADD CONSTRAINT [DF_ConfigurationPage_OverrideCssOutput] DEFAULT ((0)) FOR [OverrideCssOutput]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OverrideJavaScriptOutput' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationPage_OverrideJavaScriptOutput]', 'D'))
ALTER TABLE [dbo].[ConfigurationPage] ADD CONSTRAINT [DF_ConfigurationPage_OverrideJavaScriptOutput] DEFAULT ((0)) FOR [OverrideJavaScriptOutput]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ConfigurationQueryResultValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ResultXml' AND object_id = OBJECT_ID(N'[dbo].[ConfigurationQueryResultValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationQueryResultValue_ResultXml]', 'D'))
ALTER TABLE [dbo].[ConfigurationQueryResultValue] ADD CONSTRAINT [DF_ConfigurationQueryResultValue_ResultXml] DEFAULT ('') FOR [ResultXml]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Configuration]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HasSmartPart' AND object_id = OBJECT_ID(N'[dbo].[Configuration]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ConfigurationHeader_HasSmartPart]', 'D'))
ALTER TABLE [dbo].[Configuration] ADD CONSTRAINT [DF_ConfigurationHeader_HasSmartPart] DEFAULT ((0)) FOR [HasSmartPart]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OverrideOnRefresh' AND object_id = OBJECT_ID(N'[dbo].[Configuration]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Configuration_OverrideOnRefresh]', 'D'))
ALTER TABLE [dbo].[Configuration] ADD CONSTRAINT [DF_Configuration_OverrideOnRefresh] DEFAULT ((1)) FOR [OverrideOnRefresh]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DisplaySummary' AND object_id = OBJECT_ID(N'[dbo].[Configuration]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Configuration_DisplaySummary]', 'D'))
ALTER TABLE [dbo].[Configuration] ADD CONSTRAINT [DF_Configuration_DisplaySummary] DEFAULT ((1)) FOR [DisplaySummary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ContentItemField]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentItemField_Id]', 'D'))
ALTER TABLE [dbo].[ContentItemField] ADD CONSTRAINT [DF_ContentItemField_Id] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentItemField_CreatedOn]', 'D'))
ALTER TABLE [dbo].[ContentItemField] ADD CONSTRAINT [DF_ContentItemField_CreatedOn] DEFAULT (getdate()) FOR [CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ContentItem]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentItem_Id]', 'D'))
ALTER TABLE [dbo].[ContentItem] ADD CONSTRAINT [DF_ContentItem_Id] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPage' AND object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentItem_IsPage]', 'D'))
ALTER TABLE [dbo].[ContentItem] ADD CONSTRAINT [DF_ContentItem_IsPage] DEFAULT ((0)) FOR [IsPage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentItem_CreatedOn]', 'D'))
ALTER TABLE [dbo].[ContentItem] ADD CONSTRAINT [DF_ContentItem_CreatedOn] DEFAULT (getdate()) FOR [CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ContentPageState]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[ContentPageState]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ContentPageState_Id]', 'D'))
ALTER TABLE [dbo].[ContentPageState] ADD CONSTRAINT [DF_ContentPageState_Id] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Content]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[Content]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Content_Created]', 'D'))
ALTER TABLE [dbo].[Content] ADD CONSTRAINT [DF_Content_Created] DEFAULT (getdate()) FOR [CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Country]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Country]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Country_IsActive]', 'D'))
ALTER TABLE [dbo].[Country] ADD CONSTRAINT [DF_Country_IsActive] DEFAULT ((0)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CreditCardTransaction]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Amount' AND object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CreditCardTransaction_Amount]', 'D'))
ALTER TABLE [dbo].[CreditCardTransaction] ADD CONSTRAINT [DF_CreditCardTransaction_Amount] DEFAULT ((0)) FOR [Amount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PostedToERP' AND object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CreditCardTransaction_PostedToERP]', 'D'))
ALTER TABLE [dbo].[CreditCardTransaction] ADD CONSTRAINT [DF_CreditCardTransaction_PostedToERP] DEFAULT ((0)) FOR [PostedToERP]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CurrencyRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'EffectiveDate' AND object_id = OBJECT_ID(N'[dbo].[CurrencyRate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CurrencyRate_EffectiveDate]', 'D'))
ALTER TABLE [dbo].[CurrencyRate] ADD CONSTRAINT [DF_CurrencyRate_EffectiveDate] DEFAULT (getdate()) FOR [EffectiveDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Currency]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[Currency]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Currency_IsDefault]', 'D'))
ALTER TABLE [dbo].[Currency] ADD CONSTRAINT [DF_Currency_IsDefault] DEFAULT ((0)) FOR [IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CustomerCostCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[CustomerCostCode]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerCostCode_IsActive]', 'D'))
ALTER TABLE [dbo].[CustomerCostCode] ADD CONSTRAINT [DF_CustomerCostCode_IsActive] DEFAULT ((0)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CustomerOrderProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Value' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrderProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrderProperty_Value]', 'D'))
ALTER TABLE [dbo].[CustomerOrderProperty] ADD CONSTRAINT [DF_CustomerOrderProperty_Value] DEFAULT ('') FOR [Value]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CustomerOrder]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OrderDate' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Order_OrderDate]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [DF_Order_OrderDate] DEFAULT (getdate()) FOR [OrderDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipEarly' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_ShipEarly]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [DF_CustomerOrder_ShipEarly] DEFAULT ((1)) FOR [ShipEarly]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipPartial' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_ShipPartial]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [DF_CustomerOrder_ShipPartial] DEFAULT ((1)) FOR [ShipPartial]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerNumber' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_CustomerNumber]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [DF_CustomerOrder_CustomerNumber] DEFAULT ('') FOR [CustomerNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerSequence' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_CustomerSequence]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [DF_CustomerOrder_CustomerSequence] DEFAULT ('') FOR [CustomerSequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Residential' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_Residential]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [DF_CustomerOrder_Residential] DEFAULT ((0)) FOR [Residential]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InsideDelivery' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_InsideDelivery]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [DF_CustomerOrder_InsideDelivery] DEFAULT ((0)) FOR [InsideDelivery]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ConversionRate' AND object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerOrder_ConversionRate]', 'D'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [DF_CustomerOrder_ConversionRate] DEFAULT ((1)) FOR [ConversionRate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CustomerProductSet]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__CustomerPr__Name__69933E79]', 'D'))
ALTER TABLE [dbo].[CustomerProductSet] ADD CONSTRAINT [DF__CustomerPr__Name__69933E79] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__CustomerP__Descr__6A8762B2]', 'D'))
ALTER TABLE [dbo].[CustomerProductSet] ADD CONSTRAINT [DF__CustomerP__Descr__6A8762B2] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ActivateOn' AND object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__CustomerP__Activ__6B7B86EB]', 'D'))
ALTER TABLE [dbo].[CustomerProductSet] ADD CONSTRAINT [DF__CustomerP__Activ__6B7B86EB] DEFAULT (getdate()) FOR [ActivateOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CustomerSalesperson]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomerId' AND object_id = OBJECT_ID(N'[dbo].[CustomerSalesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerSalesperson_CustomerId]', 'D'))
ALTER TABLE [dbo].[CustomerSalesperson] ADD CONSTRAINT [DF_CustomerSalesperson_CustomerId] DEFAULT (newid()) FOR [CustomerId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalespersonId' AND object_id = OBJECT_ID(N'[dbo].[CustomerSalesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerSalesperson_SalespersonId]', 'D'))
ALTER TABLE [dbo].[CustomerSalesperson] ADD CONSTRAINT [DF_CustomerSalesperson_SalespersonId] DEFAULT (newid()) FOR [SalespersonId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[CustomerUserProfile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[CustomerUserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerUserProfile_IsDefault]', 'D'))
ALTER TABLE [dbo].[CustomerUserProfile] ADD CONSTRAINT [DF_CustomerUserProfile_IsDefault] DEFAULT ((0)) FOR [IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Customer]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipEarly' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_ShipEarly]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_ShipEarly] DEFAULT ((1)) FOR [ShipEarly]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipPartial' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_ShipPartial]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_ShipPartial] DEFAULT ((1)) FOR [ShipPartial]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreditHold' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_CreditHold]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_CreditHold] DEFAULT ((0)) FOR [CreditHold]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreditLimit' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_CreditLimit]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_CreditLimit] DEFAULT ((0)) FOR [CreditLimit]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SendEmail' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_SendEmail]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_SendEmail] DEFAULT ((0)) FOR [SendEmail]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LogoImagePath' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_Image]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_Image] DEFAULT ('') FOR [LogoImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_Active]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_Active] DEFAULT ((1)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AllowDropShip' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_AllowDropShip]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_AllowDropShip] DEFAULT ((0)) FOR [AllowDropShip]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DropShipFeeRequired' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_DropShipFeeRequired]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_DropShipFeeRequired] DEFAULT ((0)) FOR [DropShipFeeRequired]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDropShip' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_IsDropShip]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_IsDropShip] DEFAULT ((0)) FOR [IsDropShip]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsGuest' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_IsGuest]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_IsGuest] DEFAULT ((0)) FOR [IsGuest]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CustomLandingPage' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_CustomLandingPage]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_CustomLandingPage] DEFAULT ('') FOR [CustomLandingPage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IgnoreProductRestrictions' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_CustomerUserProfile_IgnoreProductRestrictions]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_CustomerUserProfile_IgnoreProductRestrictions] DEFAULT ((0)) FOR [IgnoreProductRestrictions]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ModifedOn' AND object_id = OBJECT_ID(N'[dbo].[Customer]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Customer_ModifyDate]', 'D'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [DF_Customer_ModifyDate] DEFAULT (getdate()) FOR [ModifedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[DatabaseScript]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AppliedOn' AND object_id = OBJECT_ID(N'[dbo].[DatabaseScript]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_DatabaseScript_Applied]', 'D'))
ALTER TABLE [dbo].[DatabaseScript] ADD CONSTRAINT [DF_DatabaseScript_Applied] DEFAULT (getdate()) FOR [AppliedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[DealerProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Value' AND object_id = OBJECT_ID(N'[dbo].[DealerProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_DealerProperty_Value]', 'D'))
ALTER TABLE [dbo].[DealerProperty] ADD CONSTRAINT [DF_DealerProperty_Value] DEFAULT ('') FOR [Value]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[DictionaryAttribute]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RequiredField' AND object_id = OBJECT_ID(N'[dbo].[DictionaryAttribute]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_DictionaryAttribute_RequiredField]', 'D'))
ALTER TABLE [dbo].[DictionaryAttribute] ADD CONSTRAINT [DF_DictionaryAttribute_RequiredField] DEFAULT ((0)) FOR [RequiredField]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IncludeInGrid' AND object_id = OBJECT_ID(N'[dbo].[DictionaryAttribute]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_DictionaryAttribute_IncludeInGrid]', 'D'))
ALTER TABLE [dbo].[DictionaryAttribute] ADD CONSTRAINT [DF_DictionaryAttribute_IncludeInGrid] DEFAULT ((0)) FOR [IncludeInGrid]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DefaultValue' AND object_id = OBJECT_ID(N'[dbo].[DictionaryAttribute]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_DictionaryAttribute_DefaultValue]', 'D'))
ALTER TABLE [dbo].[DictionaryAttribute] ADD CONSTRAINT [DF_DictionaryAttribute_DefaultValue] DEFAULT ('') FOR [DefaultValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Document]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Document]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Document_Description]', 'D'))
ALTER TABLE [dbo].[Document] ADD CONSTRAINT [DF_Document_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[Document]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Document_Created]', 'D'))
ALTER TABLE [dbo].[Document] ADD CONSTRAINT [DF_Document_Created] DEFAULT (getdate()) FOR [CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FilePath' AND object_id = OBJECT_ID(N'[dbo].[Document]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Document_FilePath]', 'D'))
ALTER TABLE [dbo].[Document] ADD CONSTRAINT [DF_Document_FilePath] DEFAULT ('') FOR [FilePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FileName' AND object_id = OBJECT_ID(N'[dbo].[Document]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Document_FileName]', 'D'))
ALTER TABLE [dbo].[Document] ADD CONSTRAINT [DF_Document_FileName] DEFAULT ('') FOR [FileName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DocumentType' AND object_id = OBJECT_ID(N'[dbo].[Document]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Document_DocumentType]', 'D'))
ALTER TABLE [dbo].[Document] ADD CONSTRAINT [DF_Document_DocumentType] DEFAULT ('') FOR [DocumentType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[EmailList]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CanSubscribe' AND object_id = OBJECT_ID(N'[dbo].[EmailList]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_EmailList_CanSubscribe]', 'D'))
ALTER TABLE [dbo].[EmailList] ADD CONSTRAINT [DF_EmailList_CanSubscribe] DEFAULT ((0)) FOR [CanSubscribe]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[EmailMessageAddress]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Type' AND object_id = OBJECT_ID(N'[dbo].[EmailMessageAddress]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_EmailMessageAddress_Type]', 'D'))
ALTER TABLE [dbo].[EmailMessageAddress] ADD CONSTRAINT [DF_EmailMessageAddress_Type] DEFAULT ('') FOR [Type]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[EmailMessageDeliveryAttempt]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AttemptedDateTime' AND object_id = OBJECT_ID(N'[dbo].[EmailMessageDeliveryAttempt]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_EmailMessageDeliveryAttempt_AttemptedDateTime]', 'D'))
ALTER TABLE [dbo].[EmailMessageDeliveryAttempt] ADD CONSTRAINT [DF_EmailMessageDeliveryAttempt_AttemptedDateTime] DEFAULT (getdate()) FOR [AttemptedDateTime]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[EmailMessage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SentDate' AND object_id = OBJECT_ID(N'[dbo].[EmailMessage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_EmailMessage_SentDate]', 'D'))
ALTER TABLE [dbo].[EmailMessage] ADD CONSTRAINT [DF_EmailMessage_SentDate] DEFAULT (getdate()) FOR [SentDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[EmailSubscriber]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[EmailSubscriber]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_EmailSubscriber_Id]', 'D'))
ALTER TABLE [dbo].[EmailSubscriber] ADD CONSTRAINT [DF_EmailSubscriber_Id] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[GiftCardTransaction]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TransactionDate' AND object_id = OBJECT_ID(N'[dbo].[GiftCardTransaction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_GiftCardTransaction_TransactionDate]', 'D'))
ALTER TABLE [dbo].[GiftCardTransaction] ADD CONSTRAINT [DF_GiftCardTransaction_TransactionDate] DEFAULT (getdate()) FOR [TransactionDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[GiftCard]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PurchasedOn' AND object_id = OBJECT_ID(N'[dbo].[GiftCard]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_GiftCard_Purchased]', 'D'))
ALTER TABLE [dbo].[GiftCard] ADD CONSTRAINT [DF_GiftCard_Purchased] DEFAULT (getdate()) FOR [PurchasedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[GiftCard]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_GiftCard_Active]', 'D'))
ALTER TABLE [dbo].[GiftCard] ADD CONSTRAINT [DF_GiftCard_Active] DEFAULT ((0)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[IntegrationConnection]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DebuggingEnabled' AND object_id = OBJECT_ID(N'[dbo].[IntegrationConnection]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationConnection_DebuggingEnabled]', 'D'))
ALTER TABLE [dbo].[IntegrationConnection] ADD CONSTRAINT [DF_IntegrationConnection_DebuggingEnabled] DEFAULT ((0)) FOR [DebuggingEnabled]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[IntegrationJobParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Value' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJobParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJobParameter_Value]', 'D'))
ALTER TABLE [dbo].[IntegrationJobParameter] ADD CONSTRAINT [DF_IntegrationJobParameter_Value] DEFAULT ('') FOR [Value]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[IntegrationJob]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsRealTime' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJob_IsRealTime]', 'D'))
ALTER TABLE [dbo].[IntegrationJob] ADD CONSTRAINT [DF_IntegrationJob_IsRealTime] DEFAULT ((0)) FOR [IsRealTime]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPreview' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJob_IsPreview]', 'D'))
ALTER TABLE [dbo].[IntegrationJob] ADD CONSTRAINT [DF_IntegrationJob_IsPreview] DEFAULT ((0)) FOR [IsPreview]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DeltaDataSetProcessed' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJob_DeltaDataSetProcessed]', 'D'))
ALTER TABLE [dbo].[IntegrationJob] ADD CONSTRAINT [DF_IntegrationJob_DeltaDataSetProcessed] DEFAULT ((0)) FOR [DeltaDataSetProcessed]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FileProcessed' AND object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_IntegrationJob_FileProcessed]', 'D'))
ALTER TABLE [dbo].[IntegrationJob] ADD CONSTRAINT [DF_IntegrationJob_FileProcessed] DEFAULT ((0)) FOR [FileProcessed]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[InvoiceHistory]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'InvoiceDate' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistory]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceHistory_InvoiceDate]', 'D'))
ALTER TABLE [dbo].[InvoiceHistory] ADD CONSTRAINT [DF_InvoiceHistory_InvoiceDate] DEFAULT (getdate()) FOR [InvoiceDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DueDate' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistory]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceHistory_DueDate]', 'D'))
ALTER TABLE [dbo].[InvoiceHistory] ADD CONSTRAINT [DF_InvoiceHistory_DueDate] DEFAULT (getdate()) FOR [DueDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsOpen' AND object_id = OBJECT_ID(N'[dbo].[InvoiceHistory]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_InvoiceHistory_IsOpen]', 'D'))
ALTER TABLE [dbo].[InvoiceHistory] ADD CONSTRAINT [DF_InvoiceHistory_IsOpen] DEFAULT ((0)) FOR [IsOpen]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[JobDefinitionParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionParameter_JobDefinitionParameterId]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] ADD CONSTRAINT [DF_JobDefinitionParameter_JobDefinitionParameterId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Sequence' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionParameter_Sequence]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] ADD CONSTRAINT [DF_JobDefinitionParameter_Sequence] DEFAULT ((0)) FOR [Sequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ValueType' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionParameter_ValueType]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] ADD CONSTRAINT [DF_JobDefinitionParameter_ValueType] DEFAULT ('') FOR [ValueType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DefaultValue' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionParameter_DefaultValue]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] ADD CONSTRAINT [DF_JobDefinitionParameter_DefaultValue] DEFAULT ('') FOR [DefaultValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Prompt' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionParameter_Prompt]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] ADD CONSTRAINT [DF_JobDefinitionParameter_Prompt] DEFAULT ('') FOR [Prompt]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionParameter_Name]', 'D'))
ALTER TABLE [dbo].[JobDefinitionParameter] ADD CONSTRAINT [DF_JobDefinitionParameter_Name] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[JobDefinitionStepFieldMap]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepFieldMap_JobDefinitionStepFieldMapId]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] ADD CONSTRAINT [DF_JobDefinitionStepFieldMap_JobDefinitionStepFieldMapId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FieldType' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepFieldMap_FieldType]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] ADD CONSTRAINT [DF_JobDefinitionStepFieldMap_FieldType] DEFAULT ('') FOR [FieldType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FromProperty' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepFieldMap_FromProperty]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] ADD CONSTRAINT [DF_JobDefinitionStepFieldMap_FromProperty] DEFAULT ('') FOR [FromProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ToProperty' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepFieldMap_ToProperty]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] ADD CONSTRAINT [DF_JobDefinitionStepFieldMap_ToProperty] DEFAULT ('') FOR [ToProperty]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Overwrite' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepFieldMap_Overwrite]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] ADD CONSTRAINT [DF_JobDefinitionStepFieldMap_Overwrite] DEFAULT ((0)) FOR [Overwrite]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsErpKey' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepFieldMap_IsErpKey]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] ADD CONSTRAINT [DF_JobDefinitionStepFieldMap_IsErpKey] DEFAULT ((0)) FOR [IsErpKey]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[JobDefinitionStepParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepParameter_JobDefinitionStepParameterId]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] ADD CONSTRAINT [DF_JobDefinitionStepParameter_JobDefinitionStepParameterId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Sequence' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepParameter_Sequence]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] ADD CONSTRAINT [DF_JobDefinitionStepParameter_Sequence] DEFAULT ((0)) FOR [Sequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ValueType' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepParameter_ValueType]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] ADD CONSTRAINT [DF_JobDefinitionStepParameter_ValueType] DEFAULT ('') FOR [ValueType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DefaultValue' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepParameter_DefaultValue]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] ADD CONSTRAINT [DF_JobDefinitionStepParameter_DefaultValue] DEFAULT ('') FOR [DefaultValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Prompt' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepParameter_Prompt]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] ADD CONSTRAINT [DF_JobDefinitionStepParameter_Prompt] DEFAULT ('') FOR [Prompt]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStepParameter_Name]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] ADD CONSTRAINT [DF_JobDefinitionStepParameter_Name] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[JobDefinitionStep]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_JobDefinitionStepId]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_JobDefinitionStepId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Sequence' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_Sequence]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_Sequence] DEFAULT ((0)) FOR [Sequence]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_Name]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_Name] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ObjectName' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_Object]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_Object] DEFAULT ('') FOR [ObjectName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IntegrationProcessorOverride' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_IntegrationProcessorOverride]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_IntegrationProcessorOverride] DEFAULT ('') FOR [IntegrationProcessorOverride]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SelectClause' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_SelectClause]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_SelectClause] DEFAULT ('') FOR [SelectClause]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FromClause' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_FromClause]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_FromClause] DEFAULT ('') FOR [FromClause]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'WhereClause' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_WhereClause]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_WhereClause] DEFAULT ('') FOR [WhereClause]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ParameterizedWhereClause' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_ParamaterizedWhereClause]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_ParamaterizedWhereClause] DEFAULT ('') FOR [ParameterizedWhereClause]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DeleteAction' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_DeleteAction]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_DeleteAction] DEFAULT ('Ignore') FOR [DeleteAction]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DeleteActionFieldToSet' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_DeleteActionFieldToSet]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_DeleteActionFieldToSet] DEFAULT ('') FOR [DeleteActionFieldToSet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DeleteActionValueToSet' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_DeleteActionValueToSet]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_DeleteActionValueToSet] DEFAULT ('') FOR [DeleteActionValueToSet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SkipHeaderRow' AND object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinitionStep_SkipHeaderRow]', 'D'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [DF_JobDefinitionStep_SkipHeaderRow] DEFAULT ((1)) FOR [SkipHeaderRow]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[JobDefinition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_JobDefinitionId]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_JobDefinitionId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_Name]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_Name] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_Description]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'JobType' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_JobType]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_JobType] DEFAULT ('') FOR [JobType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DebuggingEnabled' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_DebuggingEnabled]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_DebuggingEnabled] DEFAULT ((0)) FOR [DebuggingEnabled]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PassThroughJob' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_PassThroughJob]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_PassThroughJob] DEFAULT ((0)) FOR [PassThroughJob]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'NotifyEmail' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_NotifyEmail]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_NotifyEmail] DEFAULT ('') FOR [NotifyEmail]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'NotifyCondition' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_NotifyCondition]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_NotifyCondition] DEFAULT ('') FOR [NotifyCondition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PassDataSetToLinkedJob' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_PassDatasetToLinkedJob]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_PassDatasetToLinkedJob] DEFAULT ((0)) FOR [PassDataSetToLinkedJob]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'UseDeltaDataSet' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_UseDeltaDataset]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_UseDeltaDataset] DEFAULT ((0)) FOR [UseDeltaDataSet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PreProcessor' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_PreProcessor]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_PreProcessor] DEFAULT ('') FOR [PreProcessor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IntegrationProcessor' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_IntegrationProcessor]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_IntegrationProcessor] DEFAULT ('') FOR [IntegrationProcessor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PostProcessor' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_PostProcessor]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_PostProcessor] DEFAULT ('') FOR [PostProcessor]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LastRunJobNumber' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_LastRunJobNumber]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_LastRunJobNumber] DEFAULT ('') FOR [LastRunJobNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LastRunStatus' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_LastRunStatus]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_LastRunStatus] DEFAULT ('') FOR [LastRunStatus]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RecurringJob' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_RecurringJob]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_RecurringJob] DEFAULT ((0)) FOR [RecurringJob]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RecurringInterval' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_RecurringMinuteInterval]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_RecurringMinuteInterval] DEFAULT ((0)) FOR [RecurringInterval]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RecurringType' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_RecurringType]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_RecurringType] DEFAULT ('') FOR [RecurringType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RecurringStartDay' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_RecurringStartDay]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_RecurringStartDay] DEFAULT ((0)) FOR [RecurringStartDay]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RunStepsInParallel' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_RunStepsInParallel]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_RunStepsInParallel] DEFAULT ((0)) FOR [RunStepsInParallel]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LinkedJobCondition' AND object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_JobDefinition_LinkedJobCondition]', 'D'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [DF_JobDefinition_LinkedJobCondition] DEFAULT ('') FOR [LinkedJobCondition]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Language]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HasDeviceSpecificContent' AND object_id = OBJECT_ID(N'[dbo].[Language]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Language_HasDeviceSpecificContent]', 'D'))
ALTER TABLE [dbo].[Language] ADD CONSTRAINT [DF_Language_HasDeviceSpecificContent] DEFAULT ((0)) FOR [HasDeviceSpecificContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HasPersonaSpecificContent' AND object_id = OBJECT_ID(N'[dbo].[Language]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Language_HasPersonaSpecificContent]', 'D'))
ALTER TABLE [dbo].[Language] ADD CONSTRAINT [DF_Language_HasPersonaSpecificContent] DEFAULT ((0)) FOR [HasPersonaSpecificContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ImageFilePath' AND object_id = OBJECT_ID(N'[dbo].[Language]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Language_ImageFilePath]', 'D'))
ALTER TABLE [dbo].[Language] ADD CONSTRAINT [DF_Language_ImageFilePath] DEFAULT ('') FOR [ImageFilePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[Language]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Language_IsDefault]', 'D'))
ALTER TABLE [dbo].[Language] ADD CONSTRAINT [DF_Language_IsDefault] DEFAULT ((0)) FOR [IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[LocalTaxRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TaxFreight' AND object_id = OBJECT_ID(N'[dbo].[LocalTaxRate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_LocalTaxRate_TaxFreight]', 'D'))
ALTER TABLE [dbo].[LocalTaxRate] ADD CONSTRAINT [DF_LocalTaxRate_TaxFreight] DEFAULT ((0)) FOR [TaxFreight]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[MenuRole]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RoleName' AND object_id = OBJECT_ID(N'[dbo].[MenuRole]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_MenuRole_RoleName]', 'D'))
ALTER TABLE [dbo].[MenuRole] ADD CONSTRAINT [DF_MenuRole_RoleName] DEFAULT ('') FOR [RoleName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Menu]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_Description]', 'D'))
ALTER TABLE [dbo].[Menu] ADD CONSTRAINT [DF_Menu_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ImagePath' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_Image]', 'D'))
ALTER TABLE [dbo].[Menu] ADD CONSTRAINT [DF_Menu_Image] DEFAULT ('') FOR [ImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_IsActive]', 'D'))
ALTER TABLE [dbo].[Menu] ADD CONSTRAINT [DF_Menu_IsActive] DEFAULT ((1)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Target' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_Target]', 'D'))
ALTER TABLE [dbo].[Menu] ADD CONSTRAINT [DF_Menu_Target] DEFAULT ('') FOR [Target]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsGlobalItem' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_IsGlobalItem]', 'D'))
ALTER TABLE [dbo].[Menu] ADD CONSTRAINT [DF_Menu_IsGlobalItem] DEFAULT ((0)) FOR [IsGlobalItem]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsSystemItem' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_IsSystemItem]', 'D'))
ALTER TABLE [dbo].[Menu] ADD CONSTRAINT [DF_Menu_IsSystemItem] DEFAULT ((0)) FOR [IsSystemItem]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShowInList' AND object_id = OBJECT_ID(N'[dbo].[Menu]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Menu_ShowInList]', 'D'))
ALTER TABLE [dbo].[Menu] ADD CONSTRAINT [DF_Menu_ShowInList] DEFAULT ((0)) FOR [ShowInList]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[MessageAudit]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Body' AND object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_MessageAudit_Body]', 'D'))
ALTER TABLE [dbo].[MessageAudit] ADD CONSTRAINT [DF_MessageAudit_Body] DEFAULT ('') FOR [Body]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_MessageAudit_CreatedDate]', 'D'))
ALTER TABLE [dbo].[MessageAudit] ADD CONSTRAINT [DF_MessageAudit_CreatedDate] DEFAULT (getdate()) FOR [CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[MessageStatus]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HasRead' AND object_id = OBJECT_ID(N'[dbo].[MessageStatus]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_MessageStatus_HasRead]', 'D'))
ALTER TABLE [dbo].[MessageStatus] ADD CONSTRAINT [DF_MessageStatus_HasRead] DEFAULT ((0)) FOR [HasRead]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Message]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DateToDisplay' AND object_id = OBJECT_ID(N'[dbo].[Message]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Message_DateToDisplay]', 'D'))
ALTER TABLE [dbo].[Message] ADD CONSTRAINT [DF_Message_DateToDisplay] DEFAULT (getdate()) FOR [DateToDisplay]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[MiscellaneousCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AdditionalInfo' AND object_id = OBJECT_ID(N'[dbo].[MiscellaneousCode]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_MiscellaneousCode_AdditionalInfo]', 'D'))
ALTER TABLE [dbo].[MiscellaneousCode] ADD CONSTRAINT [DF_MiscellaneousCode_AdditionalInfo] DEFAULT ('') FOR [AdditionalInfo]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[MiscellaneousCode]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_MiscellaneousCode_Description]', 'D'))
ALTER TABLE [dbo].[MiscellaneousCode] ADD CONSTRAINT [DF_MiscellaneousCode_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[OrderHistoryLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[OrderHistoryLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderHistoryLine_Description]', 'D'))
ALTER TABLE [dbo].[OrderHistoryLine] ADD CONSTRAINT [DF_OrderHistoryLine_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[OrderHistory]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OrderDate' AND object_id = OBJECT_ID(N'[dbo].[OrderHistory]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderHistory_OrderDate]', 'D'))
ALTER TABLE [dbo].[OrderHistory] ADD CONSTRAINT [DF_OrderHistory_OrderDate] DEFAULT (getdate()) FOR [OrderDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ModifiedOn' AND object_id = OBJECT_ID(N'[dbo].[OrderHistory]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderHistory_ModifyDate]', 'D'))
ALTER TABLE [dbo].[OrderHistory] ADD CONSTRAINT [DF_OrderHistory_ModifyDate] DEFAULT (getdate()) FOR [ModifiedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[OrderLineConfigurationValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OptionValue' AND object_id = OBJECT_ID(N'[dbo].[OrderLineConfigurationValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLineConfigurationValue_OptionValue]', 'D'))
ALTER TABLE [dbo].[OrderLineConfigurationValue] ADD CONSTRAINT [DF_OrderLineConfigurationValue_OptionValue] DEFAULT ('') FOR [OptionValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[OrderLineProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLineProperty_OrderLinePropertyId]', 'D'))
ALTER TABLE [dbo].[OrderLineProperty] ADD CONSTRAINT [DF_OrderLineProperty_OrderLinePropertyId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLineProperty_Name]', 'D'))
ALTER TABLE [dbo].[OrderLineProperty] ADD CONSTRAINT [DF_OrderLineProperty_Name] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Value' AND object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLineProperty_Value]', 'D'))
ALTER TABLE [dbo].[OrderLineProperty] ADD CONSTRAINT [DF_OrderLineProperty_Value] DEFAULT ('') FOR [Value]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Hidden' AND object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLineProperty_Hidden]', 'D'))
ALTER TABLE [dbo].[OrderLineProperty] ADD CONSTRAINT [DF_OrderLineProperty_Hidden] DEFAULT ((0)) FOR [Hidden]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[OrderLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DueDate' AND object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLine_DueDate]', 'D'))
ALTER TABLE [dbo].[OrderLine] ADD CONSTRAINT [DF_OrderLine_DueDate] DEFAULT (getdate()) FOR [DueDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPromotionItem' AND object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderLine_IsPromotionItem]', 'D'))
ALTER TABLE [dbo].[OrderLine] ADD CONSTRAINT [DF_OrderLine_IsPromotionItem] DEFAULT ((0)) FOR [IsPromotionItem]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[OrderPromotionCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[OrderPromotionCode]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderPromotionCode_PromotionCodeId]', 'D'))
ALTER TABLE [dbo].[OrderPromotionCode] ADD CONSTRAINT [DF_OrderPromotionCode_PromotionCodeId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Code' AND object_id = OBJECT_ID(N'[dbo].[OrderPromotionCode]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_OrderPromotionCode_Code]', 'D'))
ALTER TABLE [dbo].[OrderPromotionCode] ADD CONSTRAINT [DF_OrderPromotionCode_Code] DEFAULT ('') FOR [Code]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[PaymentMethod]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PaymentMethod_PaymentTermId]', 'D'))
ALTER TABLE [dbo].[PaymentMethod] ADD CONSTRAINT [DF_PaymentMethod_PaymentTermId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PaymentMethod_Name]', 'D'))
ALTER TABLE [dbo].[PaymentMethod] ADD CONSTRAINT [DF_PaymentMethod_Name] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PaymentMethod_Description]', 'D'))
ALTER TABLE [dbo].[PaymentMethod] ADD CONSTRAINT [DF_PaymentMethod_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsCreditCard' AND object_id = OBJECT_ID(N'[dbo].[PaymentMethod]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PaymentMethod_IsCreditCard]', 'D'))
ALTER TABLE [dbo].[PaymentMethod] ADD CONSTRAINT [DF_PaymentMethod_IsCreditCard] DEFAULT ((0)) FOR [IsCreditCard]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Persona]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Persona]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Persona_Description]', 'D'))
ALTER TABLE [dbo].[Persona] ADD CONSTRAINT [DF_Persona_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ActivateOn' AND object_id = OBJECT_ID(N'[dbo].[Persona]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Persona_Active]', 'D'))
ALTER TABLE [dbo].[Persona] ADD CONSTRAINT [DF_Persona_Active] DEFAULT (getdate()) FOR [ActivateOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[Persona]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Persona_IsDefault]', 'D'))
ALTER TABLE [dbo].[Persona] ADD CONSTRAINT [DF_Persona_IsDefault] DEFAULT ((0)) FOR [IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Plugin]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Plugin]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Plugin_IsActive]', 'D'))
ALTER TABLE [dbo].[Plugin] ADD CONSTRAINT [DF_Plugin_IsActive] DEFAULT ((1)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ProductUnitOfMeasure]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductUnitOfMeasure_Description]', 'D'))
ALTER TABLE [dbo].[ProductUnitOfMeasure] ADD CONSTRAINT [DF_ProductUnitOfMeasure_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RoundingRule' AND object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductUnitOfMeasure_RoundingRule]', 'D'))
ALTER TABLE [dbo].[ProductUnitOfMeasure] ADD CONSTRAINT [DF_ProductUnitOfMeasure_RoundingRule] DEFAULT ('') FOR [RoundingRule]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductUnitOfMeasure_IsDefault]', 'D'))
ALTER TABLE [dbo].[ProductUnitOfMeasure] ADD CONSTRAINT [DF_ProductUnitOfMeasure_IsDefault] DEFAULT ((0)) FOR [IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ProductWarehouse]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDiscontinued' AND object_id = OBJECT_ID(N'[dbo].[ProductWarehouse]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ProductWarehouse_IsDiscontinued]', 'D'))
ALTER TABLE [dbo].[ProductWarehouse] ADD CONSTRAINT [DF_ProductWarehouse_IsDiscontinued] DEFAULT ((0)) FOR [IsDiscontinued]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Product]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ERPDescription' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_ERPDescription]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_ERPDescription] DEFAULT ('') FOR [ERPDescription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SmallImagePath' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SmallImagePath]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SmallImagePath] DEFAULT ('') FOR [SmallImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MediumImagePath' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_MediumImagePath]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_MediumImagePath] DEFAULT ('') FOR [MediumImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LargeImagePath' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_LargeImagePath]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_LargeImagePath] DEFAULT ('') FOR [LargeImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ActivateOn' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_Active]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_Active] DEFAULT (getdate()) FOR [ActivateOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PageTitle' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_PageTitle]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_PageTitle] DEFAULT ('') FOR [PageTitle]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DisplayPricePerPiece' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_DisplayPricePerPiece]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_DisplayPricePerPiece] DEFAULT ((1)) FOR [DisplayPricePerPiece]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsGiftCard' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsGiftCard]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_IsGiftCard] DEFAULT ((0)) FOR [IsGiftCard]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AllowAnyGiftCardAmount' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_AllowAnyGiftCardAmount]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_AllowAnyGiftCardAmount] DEFAULT ((0)) FOR [AllowAnyGiftCardAmount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsOutOfStock' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_OutOfStock]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_OutOfStock] DEFAULT ((0)) FOR [IsOutOfStock]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ERPManaged' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_ERPManaged]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_ERPManaged] DEFAULT ((0)) FOR [ERPManaged]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsSubscription' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsSubscription]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_IsSubscription] DEFAULT ((0)) FOR [IsSubscription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionFixedPrice' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionFixedPrice]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionFixedPrice] DEFAULT ((0)) FOR [SubscriptionFixedPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionAddToInitialOrder' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionIncludeInInitialOrder]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionIncludeInInitialOrder] DEFAULT ((0)) FOR [SubscriptionAddToInitialOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionAllMonths' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionAllMonths]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionAllMonths] DEFAULT ((0)) FOR [SubscriptionAllMonths]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionJanuary' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionJanuary]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionJanuary] DEFAULT ((0)) FOR [SubscriptionJanuary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionFebruary' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionFebruary]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionFebruary] DEFAULT ((0)) FOR [SubscriptionFebruary]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionMarch' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionMarch]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionMarch] DEFAULT ((0)) FOR [SubscriptionMarch]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionApril' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionApril]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionApril] DEFAULT ((0)) FOR [SubscriptionApril]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionMay' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionMay]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionMay] DEFAULT ((0)) FOR [SubscriptionMay]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionJune' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionJune]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionJune] DEFAULT ((0)) FOR [SubscriptionJune]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionJuly' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionJuly]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionJuly] DEFAULT ((0)) FOR [SubscriptionJuly]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionAugust' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionAugust]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionAugust] DEFAULT ((0)) FOR [SubscriptionAugust]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionSeptember' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionSeptember]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionSeptember] DEFAULT ((0)) FOR [SubscriptionSeptember]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionOctober' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionOctober]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionOctober] DEFAULT ((0)) FOR [SubscriptionOctober]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionNovember' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionNovember]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionNovember] DEFAULT ((0)) FOR [SubscriptionNovember]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionDecember' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_SubscriptionDecember]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_SubscriptionDecember] DEFAULT ((0)) FOR [SubscriptionDecember]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'UseVendorMarkup' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_UseVendorMarkup]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_UseVendorMarkup] DEFAULT ((1)) FOR [UseVendorMarkup]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TrackInventory' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_TrackInventory]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_TrackInventory] DEFAULT ((0)) FOR [TrackInventory]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsConfigured' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsConfigured]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_IsConfigured] DEFAULT ((0)) FOR [IsConfigured]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'UnitCost' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_UnitCost]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_UnitCost] DEFAULT ((0)) FOR [UnitCost]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HasMsds' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_HasMsds]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_HasMsds] DEFAULT ((0)) FOR [HasMsds]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsHazardousGood' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsHazardousGood]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_IsHazardousGood] DEFAULT ((0)) FOR [IsHazardousGood]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDiscontinued' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsDiscontinued]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_IsDiscontinued] DEFAULT ((0)) FOR [IsDiscontinued]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsSpecialOrder' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsSpecialOrder]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_IsSpecialOrder] DEFAULT ((0)) FOR [IsSpecialOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsFixedConfiguration' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_IsFixedConfiguration]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_IsFixedConfiguration] DEFAULT ((0)) FOR [IsFixedConfiguration]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ImageAltText' AND object_id = OBJECT_ID(N'[dbo].[Product]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Product_AltText]', 'D'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [DF_Product_AltText] DEFAULT ('') FOR [ImageAltText]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[PromotionResult]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Visible' AND object_id = OBJECT_ID(N'[dbo].[PromotionResult]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PromotionResult_Visible]', 'D'))
ALTER TABLE [dbo].[PromotionResult] ADD CONSTRAINT [DF_PromotionResult_Visible] DEFAULT ((1)) FOR [Visible]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Promotion]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DisplayMessage' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_DisplayMessage]', 'D'))
ALTER TABLE [dbo].[Promotion] ADD CONSTRAINT [DF_Promotion_DisplayMessage] DEFAULT ('') FOR [DisplayMessage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_Description]', 'D'))
ALTER TABLE [dbo].[Promotion] ADD CONSTRAINT [DF_Promotion_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DiscountAmount' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_Amount]', 'D'))
ALTER TABLE [dbo].[Promotion] ADD CONSTRAINT [DF_Promotion_Amount] DEFAULT ((0)) FOR [DiscountAmount]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ActivateOn' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Table_1_ActiveDate]', 'D'))
ALTER TABLE [dbo].[Promotion] ADD CONSTRAINT [DF_Table_1_ActiveDate] DEFAULT (getdate()) FOR [ActivateOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPercentage' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_IsPercentage]', 'D'))
ALTER TABLE [dbo].[Promotion] ADD CONSTRAINT [DF_Promotion_IsPercentage] DEFAULT ((1)) FOR [IsPercentage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsFreight' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_IsFreight]', 'D'))
ALTER TABLE [dbo].[Promotion] ADD CONSTRAINT [DF_Promotion_IsFreight] DEFAULT ((0)) FOR [IsFreight]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsAutomatic' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Table_1_AutomaticPromo]', 'D'))
ALTER TABLE [dbo].[Promotion] ADD CONSTRAINT [DF_Table_1_AutomaticPromo] DEFAULT ((0)) FOR [IsAutomatic]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsLive' AND object_id = OBJECT_ID(N'[dbo].[Promotion]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Promotion_IsActive]', 'D'))
ALTER TABLE [dbo].[Promotion] ADD CONSTRAINT [DF_Promotion_IsActive] DEFAULT ((0)) FOR [IsLive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[PunchOutOrderRequestItemOut]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_PunchOutOrderRequestLineOutId]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [DF_PunchOutOrderRequestItemOut_PunchOutOrderRequestLineOutId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_CreateDate]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [DF_PunchOutOrderRequestItemOut_CreateDate] DEFAULT (getdate()) FOR [CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__PunchOutOrderRequestItemOutt_BillToStreet]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [DF__PunchOutOrderRequestItemOutt_BillToStreet] DEFAULT ('') FOR [BillToStreet]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet2' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_BillToStreet2]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [DF_PunchOutOrderRequestItemOut_BillToStreet2] DEFAULT ('') FOR [BillToStreet2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet3' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_BillToStreet3]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [DF_PunchOutOrderRequestItemOut_BillToStreet3] DEFAULT ('') FOR [BillToStreet3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet4' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_BillToStreet4]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [DF_PunchOutOrderRequestItemOut_BillToStreet4] DEFAULT ('') FOR [BillToStreet4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet2' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_ShipToStreet2]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [DF_PunchOutOrderRequestItemOut_ShipToStreet2] DEFAULT ('') FOR [ShipToStreet2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet3' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_ShipToStreet3]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [DF_PunchOutOrderRequestItemOut_ShipToStreet3] DEFAULT ('') FOR [ShipToStreet3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet4' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestItemOut_ShipToStreet4]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [DF_PunchOutOrderRequestItemOut_ShipToStreet4] DEFAULT ('') FOR [ShipToStreet4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[PunchOutOrderRequestMessage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestValidationMessage_PunchOutOrderRequestMessageId]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] ADD CONSTRAINT [DF_PunchOutOrderRequestValidationMessage_PunchOutOrderRequestMessageId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ValidationMessageType' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestValidationMessage_PunchOutOrderRequestMessageType]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] ADD CONSTRAINT [DF_PunchOutOrderRequestValidationMessage_PunchOutOrderRequestMessageType] DEFAULT ('Unknown') FOR [ValidationMessageType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Message' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequestMessage_Message]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] ADD CONSTRAINT [DF_PunchOutOrderRequestMessage_Message] DEFAULT ('') FOR [Message]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[PunchOutOrderRequest]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_CreateDate]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_CreateDate] DEFAULT (getdate()) FOR [CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShippingDescription' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShippingDescription]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_ShippingDescription] DEFAULT ('') FOR [ShippingDescription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToEmail' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToEmail]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_BillToEmail] DEFAULT ('') FOR [BillToEmail]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToEmail' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToEmail]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_ShipToEmail] DEFAULT ('') FOR [ShipToEmail]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet2' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToStreet2]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_BillToStreet2] DEFAULT ('') FOR [BillToStreet2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet3' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToStreet3]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_BillToStreet3] DEFAULT ('') FOR [BillToStreet3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToStreet4' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToStreet4]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_BillToStreet4] DEFAULT ('') FOR [BillToStreet4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToTelephoneNumber' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToTelephoneNumber]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_BillToTelephoneNumber] DEFAULT ('') FOR [BillToTelephoneNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToTelephoneIsoCountryCode' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToTelephoneIsoCountryCode]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_BillToTelephoneIsoCountryCode] DEFAULT ('') FOR [BillToTelephoneIsoCountryCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'BillToTelephoneAreaOrCityCode' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_BillToTelephoneAreaOrCityCode]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_BillToTelephoneAreaOrCityCode] DEFAULT ('') FOR [BillToTelephoneAreaOrCityCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet2' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToStreet2]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_ShipToStreet2] DEFAULT ('') FOR [ShipToStreet2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet3' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToStreet3]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_ShipToStreet3] DEFAULT ('') FOR [ShipToStreet3]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToStreet4' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToStreet4]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_ShipToStreet4] DEFAULT ('') FOR [ShipToStreet4]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToTelephoneNumber' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToTelephoneNumber]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_ShipToTelephoneNumber] DEFAULT ('') FOR [ShipToTelephoneNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToTelephoneIsoCountryCode' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToTelephoneIsoCountryCode]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_ShipToTelephoneIsoCountryCode] DEFAULT ('') FOR [ShipToTelephoneIsoCountryCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipToTelephoneAreaOrCityCode' AND object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutOrderRequest_ShipToTelephoneAreaOrCityCode]', 'D'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [DF_PunchOutOrderRequest_ShipToTelephoneAreaOrCityCode] DEFAULT ('') FOR [ShipToTelephoneAreaOrCityCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[PunchOutSessionAccess]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSessionAccess]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutSessionAccess_CreateDate]', 'D'))
ALTER TABLE [dbo].[PunchOutSessionAccess] ADD CONSTRAINT [DF_PunchOutSessionAccess_CreateDate] DEFAULT (getdate()) FOR [CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[PunchOutSession]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSession]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutSession_CreateDate]', 'D'))
ALTER TABLE [dbo].[PunchOutSession] ADD CONSTRAINT [DF_PunchOutSession_CreateDate] DEFAULT (getdate()) FOR [CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipAddressIdResolved' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSession]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutSession_ShipAddressIdResolved]', 'D'))
ALTER TABLE [dbo].[PunchOutSession] ADD CONSTRAINT [DF_PunchOutSession_ShipAddressIdResolved] DEFAULT ((0)) FOR [ShipAddressIdResolved]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[PunchOutSetupRequest]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CreatedOn' AND object_id = OBJECT_ID(N'[dbo].[PunchOutSetupRequest]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_PunchOutSetupRequest_CreateDate]', 'D'))
ALTER TABLE [dbo].[PunchOutSetupRequest] ADD CONSTRAINT [DF_PunchOutSetupRequest_CreateDate] DEFAULT (getdate()) FOR [CreatedOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Salesperson]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_SalespersonId]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_SalespersonId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalespersonNumber' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_SalespersonNumber]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_SalespersonNumber] DEFAULT ('') FOR [SalespersonNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_Salesperson]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_Salesperson] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalesClass' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_SalesClass]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_SalesClass] DEFAULT ('') FOR [SalesClass]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Code' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_Code]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_Code] DEFAULT ('') FOR [Code]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalesManager' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_SalesManager]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_SalesManager] DEFAULT ('') FOR [SalesManager]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ReferenceNumber' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_ReferenceNumber]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_ReferenceNumber] DEFAULT ('') FOR [ReferenceNumber]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsOutsideRep' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_OutsideRep]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_OutsideRep] DEFAULT ((0)) FOR [IsOutsideRep]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalesPeriodToDate' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_SalesPeriodToDate]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_SalesPeriodToDate] DEFAULT ((0)) FOR [SalesPeriodToDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SalesYearToDate' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_SalesYearToDate]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_SalesYearToDate] DEFAULT ((0)) FOR [SalesYearToDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Email' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_Email]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_Email] DEFAULT ('') FOR [Email]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Phone1' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_Phone1]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_Phone1] DEFAULT ('') FOR [Phone1]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Phone2' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_Phone2]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_Phone2] DEFAULT ('') FOR [Phone2]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Title' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_Title]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_Title] DEFAULT ('') FOR [Title]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ImagePath' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_ImagePath]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_ImagePath] DEFAULT ('') FOR [ImagePath]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_Description]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MinMarginAllowed' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_MinMarginAllowed]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_MinMarginAllowed] DEFAULT ((0)) FOR [MinMarginAllowed]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MaxDiscountPercent' AND object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Salesperson_MaxDiscountPercent]', 'D'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [DF_Salesperson_MaxDiscountPercent] DEFAULT ((0)) FOR [MaxDiscountPercent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[SearchSynonym]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Bidirectional' AND object_id = OBJECT_ID(N'[dbo].[SearchSynonym]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_SearchSynonym_Bidirectional]', 'D'))
ALTER TABLE [dbo].[SearchSynonym] ADD CONSTRAINT [DF_SearchSynonym_Bidirectional] DEFAULT ((1)) FOR [Bidirectional]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ShipCharge]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[ShipCharge]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipCharge_Description]', 'D'))
ALTER TABLE [dbo].[ShipCharge] ADD CONSTRAINT [DF_ShipCharge_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Enable' AND object_id = OBJECT_ID(N'[dbo].[ShipCharge]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipCharge_Enable]', 'D'))
ALTER TABLE [dbo].[ShipCharge] ADD CONSTRAINT [DF_ShipCharge_Enable] DEFAULT ((0)) FOR [Enable]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ShipRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PerEach' AND object_id = OBJECT_ID(N'[dbo].[ShipRate]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipRate_PerEach]', 'D'))
ALTER TABLE [dbo].[ShipRate] ADD CONSTRAINT [DF_ShipRate_PerEach] DEFAULT ((0)) FOR [PerEach]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ShipRule]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipRuleType' AND object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipRule_ShipRuleType]', 'D'))
ALTER TABLE [dbo].[ShipRule] ADD CONSTRAINT [DF_ShipRule_ShipRuleType] DEFAULT ('') FOR [ShipRuleType]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ShipVia]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ActivateOn' AND object_id = OBJECT_ID(N'[dbo].[ShipVia]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipVia_Active]', 'D'))
ALTER TABLE [dbo].[ShipVia] ADD CONSTRAINT [DF_ShipVia_Active] DEFAULT (getdate()) FOR [ActivateOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Enable' AND object_id = OBJECT_ID(N'[dbo].[ShipVia]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipVia_Enable]', 'D'))
ALTER TABLE [dbo].[ShipVia] ADD CONSTRAINT [DF_ShipVia_Enable] DEFAULT ((0)) FOR [Enable]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[ShipVia]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipVia_IsDefault]', 'D'))
ALTER TABLE [dbo].[ShipVia] ADD CONSTRAINT [DF_ShipVia_IsDefault] DEFAULT ((0)) FOR [IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AllowScheduledShipDate' AND object_id = OBJECT_ID(N'[dbo].[ShipVia]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipVia_AllowScheduledShipDate]', 'D'))
ALTER TABLE [dbo].[ShipVia] ADD CONSTRAINT [DF_ShipVia_AllowScheduledShipDate] DEFAULT ((0)) FOR [AllowScheduledShipDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ShipmentPackageLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipmentPackageLine_PackageLineId]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] ADD CONSTRAINT [DF_ShipmentPackageLine_PackageLineId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductName' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipmentPackageLine_ProductName]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] ADD CONSTRAINT [DF_ShipmentPackageLine_ProductName] DEFAULT ('') FOR [ProductName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductDescription' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipmentPackageLine_ProductDescription]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] ADD CONSTRAINT [DF_ShipmentPackageLine_ProductDescription] DEFAULT ('') FOR [ProductDescription]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ProductCode' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipmentPackageLine_ProductCode]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] ADD CONSTRAINT [DF_ShipmentPackageLine_ProductCode] DEFAULT ('') FOR [ProductCode]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QtyOrdered' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipmentPackageLine_QuantityOrdered]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] ADD CONSTRAINT [DF_ShipmentPackageLine_QuantityOrdered] DEFAULT ((0)) FOR [QtyOrdered]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QtyShipped' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipmentPackageLine_QuantityShipped]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] ADD CONSTRAINT [DF_ShipmentPackageLine_QuantityShipped] DEFAULT ((0)) FOR [QtyShipped]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Price' AND object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShipmentPackageLine_Price]', 'D'))
ALTER TABLE [dbo].[ShipmentPackageLine] ADD CONSTRAINT [DF_ShipmentPackageLine_Price] DEFAULT ((0)) FOR [Price]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Shipment]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ShipmentDate' AND object_id = OBJECT_ID(N'[dbo].[Shipment]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Shipment_ShipmentDate]', 'D'))
ALTER TABLE [dbo].[Shipment] ADD CONSTRAINT [DF_Shipment_ShipmentDate] DEFAULT (getdate()) FOR [ShipmentDate]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[ShippingRestriction]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShippingRestriction_RestrictionId]', 'D'))
ALTER TABLE [dbo].[ShippingRestriction] ADD CONSTRAINT [DF_ShippingRestriction_RestrictionId] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShippingRestriction_IsActive]', 'D'))
ALTER TABLE [dbo].[ShippingRestriction] ADD CONSTRAINT [DF_ShippingRestriction_IsActive] DEFAULT ((0)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_ShippingRestriction_Name]', 'D'))
ALTER TABLE [dbo].[ShippingRestriction] ADD CONSTRAINT [DF_ShippingRestriction_Name] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Specification]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[Specification]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Specification_Description]', 'D'))
ALTER TABLE [dbo].[Specification] ADD CONSTRAINT [DF_Specification_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[Specification]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Specification_Active]', 'D'))
ALTER TABLE [dbo].[Specification] ADD CONSTRAINT [DF_Specification_Active] DEFAULT ((1)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[State]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Taxable' AND object_id = OBJECT_ID(N'[dbo].[State]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_State_Taxable]', 'D'))
ALTER TABLE [dbo].[State] ADD CONSTRAINT [DF_State_Taxable] DEFAULT ((0)) FOR [Taxable]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[State]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_State_Active]', 'D'))
ALTER TABLE [dbo].[State] ADD CONSTRAINT [DF_State_Active] DEFAULT ((0)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TaxFreight' AND object_id = OBJECT_ID(N'[dbo].[State]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_State_TaxFreight]', 'D'))
ALTER TABLE [dbo].[State] ADD CONSTRAINT [DF_State_TaxFreight] DEFAULT ((0)) FOR [TaxFreight]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[StyleClass]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[StyleClass]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_StyleClass_Description]', 'D'))
ALTER TABLE [dbo].[StyleClass] ADD CONSTRAINT [DF_StyleClass_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[StyleClass]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_StyleClass_IsActive]', 'D'))
ALTER TABLE [dbo].[StyleClass] ADD CONSTRAINT [DF_StyleClass_IsActive] DEFAULT ((1)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[StyleTraitValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[StyleTraitValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_StyleTraitValue_IsDefault]', 'D'))
ALTER TABLE [dbo].[StyleTraitValue] ADD CONSTRAINT [DF_StyleTraitValue_IsDefault] DEFAULT ((1)) FOR [IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[StyleTraitValue]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_StyleTraitValue_Description]', 'D'))
ALTER TABLE [dbo].[StyleTraitValue] ADD CONSTRAINT [DF_StyleTraitValue_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[StyleTrait]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[StyleTrait]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_StyleTrait_Description]', 'D'))
ALTER TABLE [dbo].[StyleTrait] ADD CONSTRAINT [DF_StyleTrait_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[Subscription]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ActivateOn' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_Active]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_Active] DEFAULT (getdate()) FOR [ActivateOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'FixedPrice' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_FixedPrice]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_FixedPrice] DEFAULT ((0)) FOR [FixedPrice]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IncludeInInitialOrder' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_IncludeInInitialOrder]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_IncludeInInitialOrder] DEFAULT ((0)) FOR [IncludeInInitialOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AllMonths' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_AllMonths]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_AllMonths] DEFAULT ((0)) FOR [AllMonths]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'January' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_January]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_January] DEFAULT ((0)) FOR [January]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'February' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_February]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_February] DEFAULT ((0)) FOR [February]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'March' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_March]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_March] DEFAULT ((0)) FOR [March]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'April' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_April]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_April] DEFAULT ((0)) FOR [April]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'May' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_May]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_May] DEFAULT ((0)) FOR [May]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'June' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_June]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_June] DEFAULT ((0)) FOR [June]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'July' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_July]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_July] DEFAULT ((0)) FOR [July]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'August' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_August]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_August] DEFAULT ((0)) FOR [August]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'October' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_October]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_October] DEFAULT ((0)) FOR [October]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'November' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_November]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_November] DEFAULT ((0)) FOR [November]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'December' AND object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_Subscription_December]', 'D'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [DF_Subscription_December] DEFAULT ((0)) FOR [December]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[TaxExemption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ActivateOn' AND object_id = OBJECT_ID(N'[dbo].[TaxExemption]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_TaxExemption_Active]', 'D'))
ALTER TABLE [dbo].[TaxExemption] ADD CONSTRAINT [DF_TaxExemption_Active] DEFAULT (getdate()) FOR [ActivateOn]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[TranslationProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'TranslatedValue' AND object_id = OBJECT_ID(N'[dbo].[TranslationProperty]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_TranslationProperty_TranslatedValue]', 'D'))
ALTER TABLE [dbo].[TranslationProperty] ADD CONSTRAINT [DF_TranslationProperty_TranslatedValue] DEFAULT ('') FOR [TranslatedValue]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[UserProfilePassword]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[UserProfilePassword]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfilePassword_Id]', 'D'))
ALTER TABLE [dbo].[UserProfilePassword] ADD CONSTRAINT [DF_UserProfilePassword_Id] DEFAULT (newsequentialid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[UserProfile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CanChangePassword' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_CanChangePassword]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_CanChangePassword] DEFAULT ((0)) FOR [CanChangePassword]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CanSubmitOrder' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_CanSubmitOrder]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_CanSubmitOrder] DEFAULT ((0)) FOR [CanSubmitOrder]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'CanViewAllOrders' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_CanViewAllOrders]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_CanViewAllOrders] DEFAULT ((0)) FOR [CanViewAllOrders]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsSubscribed' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_IsSubscribed]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_IsSubscribed] DEFAULT ((0)) FOR [IsSubscribed]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ApplicationName' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_ApplicationName]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_ApplicationName] DEFAULT (N'/') FOR [ApplicationName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'SubscriptionUser' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_SubscriptionUser]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_SubscriptionUser] DEFAULT ((0)) FOR [SubscriptionUser]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsGuest' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_IsGuest]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_IsGuest] DEFAULT ((0)) FOR [IsGuest]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsReviewingContent' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_IsReviewingContent]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_IsReviewingContent] DEFAULT ((0)) FOR [IsReviewingContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'LimitExceededNotification' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_LimitExceededNotification]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_LimitExceededNotification] DEFAULT ((0)) FOR [LimitExceededNotification]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsEditingContent' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_IsEditingContent]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_IsEditingContent] DEFAULT ((0)) FOR [IsEditingContent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DashboardIsHomepage' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_DashboardIsHomepage]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_DashboardIsHomepage] DEFAULT ((0)) FOR [DashboardIsHomepage]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsPasswordChangeRequired' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_IsPasswordChangeRequired]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_IsPasswordChangeRequired] DEFAULT ((0)) FOR [IsPasswordChangeRequired]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'HasRfqUpdates' AND object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_UserProfile_HasRfqUpdates]', 'D'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [DF_UserProfile_HasRfqUpdates] DEFAULT ((0)) FOR [HasRfqUpdates]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[WebPageContent]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'OverrideParent' AND object_id = OBJECT_ID(N'[dbo].[WebPageContent]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebPageContent_OverrideParent]', 'D'))
ALTER TABLE [dbo].[WebPageContent] ADD CONSTRAINT [DF_WebPageContent_OverrideParent] DEFAULT ((0)) FOR [OverrideParent]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[WebSiteConfiguration]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Value' AND object_id = OBJECT_ID(N'[dbo].[WebSiteConfiguration]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSiteConfiguration_Value]', 'D'))
ALTER TABLE [dbo].[WebSiteConfiguration] ADD CONSTRAINT [DF_WebSiteConfiguration_Value] DEFAULT ('') FOR [Value]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[WebSiteConfiguration]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSiteConfiguration_Description]', 'D'))
ALTER TABLE [dbo].[WebSiteConfiguration] ADD CONSTRAINT [DF_WebSiteConfiguration_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[WebSiteCurrency]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsLive' AND object_id = OBJECT_ID(N'[dbo].[WebSiteCurrency]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSiteCurrency_IsLive]', 'D'))
ALTER TABLE [dbo].[WebSiteCurrency] ADD CONSTRAINT [DF_WebSiteCurrency_IsLive] DEFAULT ((0)) FOR [IsLive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[WebSiteCurrency]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSiteCurrency_IsDefault]', 'D'))
ALTER TABLE [dbo].[WebSiteCurrency] ADD CONSTRAINT [DF_WebSiteCurrency_IsDefault] DEFAULT ((0)) FOR [IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[WebSiteLanguage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsDefault' AND object_id = OBJECT_ID(N'[dbo].[WebSiteLanguage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSiteLanguage_IsDefault]', 'D'))
ALTER TABLE [dbo].[WebSiteLanguage] ADD CONSTRAINT [DF_WebSiteLanguage_IsDefault] DEFAULT ((0)) FOR [IsDefault]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsLive' AND object_id = OBJECT_ID(N'[dbo].[WebSiteLanguage]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSiteLanguage_IsLive]', 'D'))
ALTER TABLE [dbo].[WebSiteLanguage] ADD CONSTRAINT [DF_WebSiteLanguage_IsLive] DEFAULT ((1)) FOR [IsLive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[WebSite]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Description' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_Description]', 'D'))
ALTER TABLE [dbo].[WebSite] ADD CONSTRAINT [DF_WebSite_Description] DEFAULT ('') FOR [Description]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'DomainName' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_DomainName]', 'D'))
ALTER TABLE [dbo].[WebSite] ADD CONSTRAINT [DF_WebSite_DomainName] DEFAULT ('') FOR [DomainName]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MapProductsToCategories' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_MapProductsToCategories]', 'D'))
ALTER TABLE [dbo].[WebSite] ADD CONSTRAINT [DF_WebSite_MapProductsToCategories] DEFAULT ((0)) FOR [MapProductsToCategories]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'AllowMultiplePromotions' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_AllowMultiplePromotions]', 'D'))
ALTER TABLE [dbo].[WebSite] ADD CONSTRAINT [DF_WebSite_AllowMultiplePromotions] DEFAULT ((0)) FOR [AllowMultiplePromotions]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsActive' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_IsActive]', 'D'))
ALTER TABLE [dbo].[WebSite] ADD CONSTRAINT [DF_WebSite_IsActive] DEFAULT ((1)) FOR [IsActive]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsRestricted' AND object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF_WebSite_IsRestricted]', 'D'))
ALTER TABLE [dbo].[WebSite] ADD CONSTRAINT [DF_WebSite_IsRestricted] DEFAULT ((0)) FOR [IsRestricted]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[WishListProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'QtyOrdered' AND object_id = OBJECT_ID(N'[dbo].[WishListProduct]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__WishListP__QtyOr__721D9782]', 'D'))
ALTER TABLE [dbo].[WishListProduct] ADD CONSTRAINT [DF__WishListP__QtyOr__721D9782] DEFAULT ((1)) FOR [QtyOrdered]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[WishList]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Name' AND object_id = OBJECT_ID(N'[dbo].[WishList]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__WishList__Name__7BA701BC]', 'D'))
ALTER TABLE [dbo].[WishList] ADD CONSTRAINT [DF__WishList__Name__7BA701BC] DEFAULT ('') FOR [Name]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[aspnet_Applications]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'ApplicationId' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Applications]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__aspnet_Ap__Appli__29221CFB]', 'D'))
ALTER TABLE [dbo].[aspnet_Applications] ADD CONSTRAINT [DF__aspnet_Ap__Appli__29221CFB] DEFAULT (newid()) FOR [ApplicationId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[aspnet_Membership]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PasswordFormat' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Membership]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__aspnet_Me__Passw__3E1D39E1]', 'D'))
ALTER TABLE [dbo].[aspnet_Membership] ADD CONSTRAINT [DF__aspnet_Me__Passw__3E1D39E1] DEFAULT ((0)) FOR [PasswordFormat]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[aspnet_Paths]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'PathId' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Paths]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__aspnet_Pa__PathI__6EC0713C]', 'D'))
ALTER TABLE [dbo].[aspnet_Paths] ADD CONSTRAINT [DF__aspnet_Pa__PathI__6EC0713C] DEFAULT (newid()) FOR [PathId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[aspnet_PersonalizationPerUser]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'Id' AND object_id = OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__aspnet_Perso__Id__76619304]', 'D'))
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] ADD CONSTRAINT [DF__aspnet_Perso__Id__76619304] DEFAULT (newid()) FOR [Id]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[aspnet_Roles]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'RoleId' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Roles]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__aspnet_Ro__RoleI__5BAD9CC8]', 'D'))
ALTER TABLE [dbo].[aspnet_Roles] ADD CONSTRAINT [DF__aspnet_Ro__RoleI__5BAD9CC8] DEFAULT (newid()) FOR [RoleId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding constraints to [dbo].[aspnet_Users]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'UserId' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Users]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__aspnet_Us__UserI__2CF2ADDF]', 'D'))
ALTER TABLE [dbo].[aspnet_Users] ADD CONSTRAINT [DF__aspnet_Us__UserI__2CF2ADDF] DEFAULT (newid()) FOR [UserId]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'MobileAlias' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Users]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__aspnet_Us__Mobil__2DE6D218]', 'D'))
ALTER TABLE [dbo].[aspnet_Users] ADD CONSTRAINT [DF__aspnet_Us__Mobil__2DE6D218] DEFAULT (NULL) FOR [MobileAlias]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE name = N'IsAnonymous' AND object_id = OBJECT_ID(N'[dbo].[aspnet_Users]', 'U') AND default_object_id = OBJECT_ID(N'[dbo].[DF__aspnet_Us__IsAno__2EDAF651]', 'D'))
ALTER TABLE [dbo].[aspnet_Users] ADD CONSTRAINT [DF__aspnet_Us__IsAno__2EDAF651] DEFAULT ((0)) FOR [IsAnonymous]
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Content]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Content_ApprovedBy]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Content]', 'U'))
ALTER TABLE [dbo].[Content] WITH NOCHECK  ADD CONSTRAINT [FK_Content_ApprovedBy] FOREIGN KEY ([ApprovedById]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Content_ContentManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Content]', 'U'))
ALTER TABLE [dbo].[Content] WITH NOCHECK  ADD CONSTRAINT [FK_Content_ContentManager] FOREIGN KEY ([ContentManagerId]) REFERENCES [dbo].[ContentManager] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Content_CreatedBy]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Content]', 'U'))
ALTER TABLE [dbo].[Content] WITH NOCHECK  ADD CONSTRAINT [FK_Content_CreatedBy] FOREIGN KEY ([CreatedById]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Product]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_DocumentManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] WITH NOCHECK  ADD CONSTRAINT [FK_Product_DocumentManager] FOREIGN KEY ([DocumentManagerId]) REFERENCES [dbo].[DocumentManager] ([Id]) ON DELETE SET NULL
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] WITH NOCHECK  ADD CONSTRAINT [FK_Product_ShipVia] FOREIGN KEY ([SubscriptionShipViaId]) REFERENCES [dbo].[ShipVia] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_StyleClass]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] WITH NOCHECK  ADD CONSTRAINT [FK_Product_StyleClass] FOREIGN KEY ([StyleClassId]) REFERENCES [dbo].[StyleClass] ([Id]) ON DELETE SET NULL
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_Vendor]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] WITH NOCHECK  ADD CONSTRAINT [FK_Product_Vendor] FOREIGN KEY ([VendorId]) REFERENCES [dbo].[Vendor] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebSite]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSite_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSite]', 'U'))
ALTER TABLE [dbo].[WebSite] WITH NOCHECK  ADD CONSTRAINT [FK_WebSite_WebSite] FOREIGN KEY ([ParentWebSiteId]) REFERENCES [dbo].[WebSite] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerOrder]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Affiliate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_Affiliate] FOREIGN KEY ([AffiliateId]) REFERENCES [dbo].[Affiliate] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Warehouse]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_Warehouse] FOREIGN KEY ([DefaultWarehouseId]) REFERENCES [dbo].[Warehouse] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_ApproverUserProfileId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_ApproverUserProfileId] FOREIGN KEY ([ApproverUserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_Currency] FOREIGN KEY ([CurrencyId]) REFERENCES [dbo].[Currency] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_CustomerOrder] FOREIGN KEY ([Id]) REFERENCES [dbo].[CustomerOrder] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_CustomerOrder1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_CustomerOrder1] FOREIGN KEY ([Id]) REFERENCES [dbo].[CustomerOrder] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_DropShipCustomer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_DropShipCustomer] FOREIGN KEY ([DropShipCustomerId]) REFERENCES [dbo].[Customer] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_InitiatedByUserProfileId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_InitiatedByUserProfileId] FOREIGN KEY ([InitiatedByUserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_QuotedBy]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_QuotedBy] FOREIGN KEY ([QuotedByUserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Salesperson]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_Salesperson] FOREIGN KEY ([SalespersonId]) REFERENCES [dbo].[Salesperson] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_ShipTo]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_ShipTo] FOREIGN KEY ([ShipToId]) REFERENCES [dbo].[Customer] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_ShipVia] FOREIGN KEY ([ShipViaId]) REFERENCES [dbo].[ShipVia] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_Subscription]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_Subscription] FOREIGN KEY ([SubscriptionId]) REFERENCES [dbo].[Subscription] ([Id]) ON DELETE SET NULL
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrder_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrder]', 'U'))
ALTER TABLE [dbo].[CustomerOrder] ADD CONSTRAINT [FK_CustomerOrder_WebSite] FOREIGN KEY ([WebsiteId]) REFERENCES [dbo].[WebSite] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PromotionRule]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Affiliate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_Affiliate] FOREIGN KEY ([AffiliateId]) REFERENCES [dbo].[Affiliate] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_PaymentMethod]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_PaymentMethod] FOREIGN KEY ([PaymentMethodId]) REFERENCES [dbo].[PaymentMethod] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_ContainedPromotion]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_ContainedPromotion] FOREIGN KEY ([ContainedPromotionId]) REFERENCES [dbo].[Promotion] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Country]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_Country] FOREIGN KEY ([CountryId]) REFERENCES [dbo].[Country] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_Currency] FOREIGN KEY ([CurrencyId]) REFERENCES [dbo].[Currency] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Persona]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_Persona] FOREIGN KEY ([PersonaId]) REFERENCES [dbo].[Persona] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Promotion]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_Promotion] FOREIGN KEY ([PromotionId]) REFERENCES [dbo].[Promotion] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Salesperson]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_Salesperson] FOREIGN KEY ([SalespersonId]) REFERENCES [dbo].[Salesperson] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_ShipVia] FOREIGN KEY ([ShipViaId]) REFERENCES [dbo].[ShipVia] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_State] FOREIGN KEY ([StateId]) REFERENCES [dbo].[State] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionRule_Vendor]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionRule]', 'U'))
ALTER TABLE [dbo].[PromotionRule] ADD CONSTRAINT [FK_PromotionRule_Vendor] FOREIGN KEY ([VendorId]) REFERENCES [dbo].[Vendor] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[DictionaryAttribute]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DictionaryAttribute_ApplicationDictionary]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DictionaryAttribute]', 'U'))
ALTER TABLE [dbo].[DictionaryAttribute] ADD CONSTRAINT [FK_DictionaryAttribute_ApplicationDictionary] FOREIGN KEY ([ApplicationDictionaryId]) REFERENCES [dbo].[ApplicationDictionary] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[DictionaryLabel]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DictionaryLabel_ApplicationDictionary]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DictionaryLabel]', 'U'))
ALTER TABLE [dbo].[DictionaryLabel] ADD CONSTRAINT [FK_DictionaryLabel_ApplicationDictionary] FOREIGN KEY ([ApplicationDictionaryId]) REFERENCES [dbo].[ApplicationDictionary] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DictionaryLabel_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DictionaryLabel]', 'U'))
ALTER TABLE [dbo].[DictionaryLabel] ADD CONSTRAINT [FK_DictionaryLabel_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CategoryAttributeType]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AttributeType_CategoryAttributeType]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U'))
ALTER TABLE [dbo].[CategoryAttributeType] ADD CONSTRAINT [FK_AttributeType_CategoryAttributeType] FOREIGN KEY ([AttributeTypeId]) REFERENCES [dbo].[AttributeType] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryAttributeType_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryAttributeType]', 'U'))
ALTER TABLE [dbo].[CategoryAttributeType] ADD CONSTRAINT [FK_CategoryAttributeType_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[AttributeValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_AttributeValue_Attribute]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[AttributeValue]', 'U'))
ALTER TABLE [dbo].[AttributeValue] ADD CONSTRAINT [FK_AttributeValue_Attribute] FOREIGN KEY ([AttributeTypeId]) REFERENCES [dbo].[AttributeType] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CategoryAttributeValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryAttributeValue_AttributeValue]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryAttributeValue]', 'U'))
ALTER TABLE [dbo].[CategoryAttributeValue] ADD CONSTRAINT [FK_CategoryAttributeValue_AttributeValue] FOREIGN KEY ([AttributeValueId]) REFERENCES [dbo].[AttributeValue] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryAttributeValue_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryAttributeValue]', 'U'))
ALTER TABLE [dbo].[CategoryAttributeValue] ADD CONSTRAINT [FK_CategoryAttributeValue_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ProductAttributeValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductAttribute_AttributeValue]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductAttributeValue]', 'U'))
ALTER TABLE [dbo].[ProductAttributeValue] ADD CONSTRAINT [FK_ProductAttribute_AttributeValue] FOREIGN KEY ([AttributeValueId]) REFERENCES [dbo].[AttributeValue] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductAttributeValue_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductAttributeValue]', 'U'))
ALTER TABLE [dbo].[ProductAttributeValue] ADD CONSTRAINT [FK_ProductAttributeValue_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[BudgetCalendar]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_BudgetCalendar_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[BudgetCalendar]', 'U'))
ALTER TABLE [dbo].[BudgetCalendar] ADD CONSTRAINT [FK_BudgetCalendar_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CarrierPackage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CarrierPackage_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierPackage]', 'U'))
ALTER TABLE [dbo].[CarrierPackage] ADD CONSTRAINT [FK_CarrierPackage_Carrier] FOREIGN KEY ([CarrierId]) REFERENCES [dbo].[Carrier] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CarrierZonePostalCodeRange]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CarrierZonePostalCodeRange_CarrierZone]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierZonePostalCodeRange]', 'U'))
ALTER TABLE [dbo].[CarrierZonePostalCodeRange] ADD CONSTRAINT [FK_CarrierZonePostalCodeRange_CarrierZone] FOREIGN KEY ([CarrierZoneId]) REFERENCES [dbo].[CarrierZone] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CarrierZoneRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CarrierZoneRate_CarrierZone]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierZoneRate]', 'U'))
ALTER TABLE [dbo].[CarrierZoneRate] ADD CONSTRAINT [FK_CarrierZoneRate_CarrierZone] FOREIGN KEY ([CarrierZoneId]) REFERENCES [dbo].[CarrierZone] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CarrierZone]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CarrierZone_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CarrierZone]', 'U'))
ALTER TABLE [dbo].[CarrierZone] ADD CONSTRAINT [FK_CarrierZone_Carrier] FOREIGN KEY ([CarrierId]) REFERENCES [dbo].[Carrier] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Carrier]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Carrier_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U'))
ALTER TABLE [dbo].[Carrier] ADD CONSTRAINT [FK_Carrier_Carrier] FOREIGN KEY ([BackUpCarrierId]) REFERENCES [dbo].[Carrier] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Carrier_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Carrier]', 'U'))
ALTER TABLE [dbo].[Carrier] ADD CONSTRAINT [FK_Carrier_Currency] FOREIGN KEY ([CurrencyId]) REFERENCES [dbo].[Currency] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CategoryProductCrossSell]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryProductCrossSell_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProductCrossSell]', 'U'))
ALTER TABLE [dbo].[CategoryProductCrossSell] ADD CONSTRAINT [FK_CategoryProductCrossSell_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryProductCrossSell_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProductCrossSell]', 'U'))
ALTER TABLE [dbo].[CategoryProductCrossSell] ADD CONSTRAINT [FK_CategoryProductCrossSell_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CategoryProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryProduct_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProduct]', 'U'))
ALTER TABLE [dbo].[CategoryProduct] ADD CONSTRAINT [FK_CategoryProduct_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProduct]', 'U'))
ALTER TABLE [dbo].[CategoryProduct] ADD CONSTRAINT [FK_CategoryProduct_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CategoryProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryProperty_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryProperty]', 'U'))
ALTER TABLE [dbo].[CategoryProperty] ADD CONSTRAINT [FK_CategoryProperty_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CategoryRelatedProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryRelatedProduct_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryRelatedProduct]', 'U'))
ALTER TABLE [dbo].[CategoryRelatedProduct] ADD CONSTRAINT [FK_CategoryRelatedProduct_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryRelatedProduct_MiscellaneousCode]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryRelatedProduct]', 'U'))
ALTER TABLE [dbo].[CategoryRelatedProduct] ADD CONSTRAINT [FK_CategoryRelatedProduct_MiscellaneousCode] FOREIGN KEY ([ProductRelationshipMiscId]) REFERENCES [dbo].[MiscellaneousCode] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryRelatedProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryRelatedProduct]', 'U'))
ALTER TABLE [dbo].[CategoryRelatedProduct] ADD CONSTRAINT [FK_CategoryRelatedProduct_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CategorySpecification]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategorySpecification_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategorySpecification]', 'U'))
ALTER TABLE [dbo].[CategorySpecification] ADD CONSTRAINT [FK_CategorySpecification_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategorySpecification_Specification]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategorySpecification]', 'U'))
ALTER TABLE [dbo].[CategorySpecification] ADD CONSTRAINT [FK_CategorySpecification_Specification] FOREIGN KEY ([SpecificationId]) REFERENCES [dbo].[Specification] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CategoryTaxExemption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryTaxExemption_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryTaxExemption]', 'U'))
ALTER TABLE [dbo].[CategoryTaxExemption] ADD CONSTRAINT [FK_CategoryTaxExemption_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CategoryTaxExemption_TaxExemption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CategoryTaxExemption]', 'U'))
ALTER TABLE [dbo].[CategoryTaxExemption] ADD CONSTRAINT [FK_CategoryTaxExemption_TaxExemption] FOREIGN KEY ([TaxExemptionId]) REFERENCES [dbo].[TaxExemption] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Category]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category_DocumentManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Category]', 'U'))
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [FK_Category_DocumentManager] FOREIGN KEY ([DocumentManagerId]) REFERENCES [dbo].[DocumentManager] ([Id]) ON DELETE SET NULL
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category_RuleManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Category]', 'U'))
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [FK_Category_RuleManager] FOREIGN KEY ([RuleManagerId]) REFERENCES [dbo].[RuleManager] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Category_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Category]', 'U'))
ALTER TABLE [dbo].[Category] ADD CONSTRAINT [FK_Category_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Company]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Company_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Company]', 'U'))
ALTER TABLE [dbo].[Company] ADD CONSTRAINT [FK_Company_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ConfigurationConditionFilter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ConfigurationConditionFilter_ConfigurationOptionCondition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationConditionFilter]', 'U'))
ALTER TABLE [dbo].[ConfigurationConditionFilter] ADD CONSTRAINT [FK_ConfigurationConditionFilter_ConfigurationOptionCondition] FOREIGN KEY ([ConfigurationOptionConditionId]) REFERENCES [dbo].[ConfigurationOptionCondition] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ConfigurationOptionCondition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ConfigurationOptionCondition_ConfigurationOption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationOptionCondition]', 'U'))
ALTER TABLE [dbo].[ConfigurationOptionCondition] ADD CONSTRAINT [FK_ConfigurationOptionCondition_ConfigurationOption] FOREIGN KEY ([ConfigurationOptionId]) REFERENCES [dbo].[ConfigurationOption] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ConfigurationPage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ConfigurationPage_Configuration]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationPage]', 'U'))
ALTER TABLE [dbo].[ConfigurationPage] ADD CONSTRAINT [FK_ConfigurationPage_Configuration] FOREIGN KEY ([ConfigurationId]) REFERENCES [dbo].[Configuration] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ConfigurationQueryResultField]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ConfigurationQueryResultField_ConfigurationQueryResult]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationQueryResultField]', 'U'))
ALTER TABLE [dbo].[ConfigurationQueryResultField] ADD CONSTRAINT [FK_ConfigurationQueryResultField_ConfigurationQueryResult] FOREIGN KEY ([ConfigurationQueryResultId]) REFERENCES [dbo].[ConfigurationQueryResult] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ConfigurationQueryResultValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ConfigurationQueryResultValue_ConfigurationQueryResult]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ConfigurationQueryResultValue]', 'U'))
ALTER TABLE [dbo].[ConfigurationQueryResultValue] ADD CONSTRAINT [FK_ConfigurationQueryResultValue_ConfigurationQueryResult] FOREIGN KEY ([ConfigurationQueryResultId]) REFERENCES [dbo].[ConfigurationQueryResult] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ContentItemField]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItemField_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U'))
ALTER TABLE [dbo].[ContentItemField] ADD CONSTRAINT [FK_ContentItemField_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItemField_Persona]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U'))
ALTER TABLE [dbo].[ContentItemField] ADD CONSTRAINT [FK_ContentItemField_Persona] FOREIGN KEY ([PersonaId]) REFERENCES [dbo].[Persona] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItemField_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U'))
ALTER TABLE [dbo].[ContentItemField] ADD CONSTRAINT [FK_ContentItemField_UserProfile] FOREIGN KEY ([CreatedById]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItemField_UserProfile1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItemField]', 'U'))
ALTER TABLE [dbo].[ContentItemField] ADD CONSTRAINT [FK_ContentItemField_UserProfile1] FOREIGN KEY ([ApprovedById]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ContentItem]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItem_UserProfile_ApprovedById]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U'))
ALTER TABLE [dbo].[ContentItem] ADD CONSTRAINT [FK_ContentItem_UserProfile_ApprovedById] FOREIGN KEY ([ApprovedById]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItem_UserProfile_CreatedById]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U'))
ALTER TABLE [dbo].[ContentItem] ADD CONSTRAINT [FK_ContentItem_UserProfile_CreatedById] FOREIGN KEY ([CreatedById]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentItem_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentItem]', 'U'))
ALTER TABLE [dbo].[ContentItem] ADD CONSTRAINT [FK_ContentItem_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ContentPageState]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentPageState_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentPageState]', 'U'))
ALTER TABLE [dbo].[ContentPageState] ADD CONSTRAINT [FK_ContentPageState_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentPageState_Persona]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentPageState]', 'U'))
ALTER TABLE [dbo].[ContentPageState] ADD CONSTRAINT [FK_ContentPageState_Persona] FOREIGN KEY ([PersonaId]) REFERENCES [dbo].[Persona] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ContentPageState_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ContentPageState]', 'U'))
ALTER TABLE [dbo].[ContentPageState] ADD CONSTRAINT [FK_ContentPageState_WebSite] FOREIGN KEY ([WebsiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Content]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Content_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Content]', 'U'))
ALTER TABLE [dbo].[Content] ADD CONSTRAINT [FK_Content_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Content_Persona]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Content]', 'U'))
ALTER TABLE [dbo].[Content] ADD CONSTRAINT [FK_Content_Persona] FOREIGN KEY ([PersonaId]) REFERENCES [dbo].[Persona] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CreditCardTransaction]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CreditCardTransaction_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]', 'U'))
ALTER TABLE [dbo].[CreditCardTransaction] ADD CONSTRAINT [FK_CreditCardTransaction_Currency] FOREIGN KEY ([CurrencyId]) REFERENCES [dbo].[Currency] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CreditCardTransaction_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CreditCardTransaction]', 'U'))
ALTER TABLE [dbo].[CreditCardTransaction] ADD CONSTRAINT [FK_CreditCardTransaction_CustomerOrder] FOREIGN KEY ([CustomerOrderId]) REFERENCES [dbo].[CustomerOrder] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CurrencyRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CurrencyRate_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CurrencyRate]', 'U'))
ALTER TABLE [dbo].[CurrencyRate] ADD CONSTRAINT [FK_CurrencyRate_Currency] FOREIGN KEY ([CurrencyId]) REFERENCES [dbo].[Currency] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerBudget]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerBudget_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerBudget]', 'U'))
ALTER TABLE [dbo].[CustomerBudget] ADD CONSTRAINT [FK_CustomerBudget_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerBudget_ShipToCustomer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerBudget]', 'U'))
ALTER TABLE [dbo].[CustomerBudget] ADD CONSTRAINT [FK_CustomerBudget_ShipToCustomer] FOREIGN KEY ([ShipToCustomerId]) REFERENCES [dbo].[Customer] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerBudget_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerBudget]', 'U'))
ALTER TABLE [dbo].[CustomerBudget] ADD CONSTRAINT [FK_CustomerBudget_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerCarrier]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerCarrier_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerCarrier]', 'U'))
ALTER TABLE [dbo].[CustomerCarrier] ADD CONSTRAINT [FK_CustomerCarrier_Carrier] FOREIGN KEY ([CarrierId]) REFERENCES [dbo].[Carrier] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerCarrier_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerCarrier]', 'U'))
ALTER TABLE [dbo].[CustomerCarrier] ADD CONSTRAINT [FK_CustomerCarrier_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerCostCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerCostCode_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerCostCode]', 'U'))
ALTER TABLE [dbo].[CustomerCostCode] ADD CONSTRAINT [FK_CustomerCostCode_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerOrderGiftCard]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrderGiftCard_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrderGiftCard]', 'U'))
ALTER TABLE [dbo].[CustomerOrderGiftCard] ADD CONSTRAINT [FK_CustomerOrderGiftCard_CustomerOrder] FOREIGN KEY ([CustomerOrderId]) REFERENCES [dbo].[CustomerOrder] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrderGiftCard_GiftCard]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrderGiftCard]', 'U'))
ALTER TABLE [dbo].[CustomerOrderGiftCard] ADD CONSTRAINT [FK_CustomerOrderGiftCard_GiftCard] FOREIGN KEY ([GiftCardId]) REFERENCES [dbo].[GiftCard] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerOrderPromotion]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrderPromotion_CustomerOrderId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrderPromotion]', 'U'))
ALTER TABLE [dbo].[CustomerOrderPromotion] ADD CONSTRAINT [FK_CustomerOrderPromotion_CustomerOrderId] FOREIGN KEY ([CustomerOrderId]) REFERENCES [dbo].[CustomerOrder] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerOrderPromotion_PromotionId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrderPromotion]', 'U'))
ALTER TABLE [dbo].[CustomerOrderPromotion] ADD CONSTRAINT [FK_CustomerOrderPromotion_PromotionId] FOREIGN KEY ([PromotionId]) REFERENCES [dbo].[Promotion] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerOrderProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DCustomerOrderProperty_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerOrderProperty]', 'U'))
ALTER TABLE [dbo].[CustomerOrderProperty] ADD CONSTRAINT [FK_DCustomerOrderProperty_CustomerOrder] FOREIGN KEY ([CustomerOrderId]) REFERENCES [dbo].[CustomerOrder] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerProductSetProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProductSetProduct_CustomerProductSet]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProductSetProduct]', 'U'))
ALTER TABLE [dbo].[CustomerProductSetProduct] ADD CONSTRAINT [FK_CustomerProductSetProduct_CustomerProductSet] FOREIGN KEY ([CustomerProductSetId]) REFERENCES [dbo].[CustomerProductSet] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProductSetProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProductSetProduct]', 'U'))
ALTER TABLE [dbo].[CustomerProductSetProduct] ADD CONSTRAINT [FK_CustomerProductSetProduct_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerProductSet]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProductSet_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProductSet]', 'U'))
ALTER TABLE [dbo].[CustomerProductSet] ADD CONSTRAINT [FK_CustomerProductSet_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProduct_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProduct]', 'U'))
ALTER TABLE [dbo].[CustomerProduct] ADD CONSTRAINT [FK_CustomerProduct_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProduct]', 'U'))
ALTER TABLE [dbo].[CustomerProduct] ADD CONSTRAINT [FK_CustomerProduct_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerProperty_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerProperty]', 'U'))
ALTER TABLE [dbo].[CustomerProperty] ADD CONSTRAINT [FK_CustomerProperty_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[CustomerUserProfile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerUserProfile_CustomerId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerUserProfile]', 'U'))
ALTER TABLE [dbo].[CustomerUserProfile] ADD CONSTRAINT [FK_CustomerUserProfile_CustomerId] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_CustomerUserProfile_UserProfileId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[CustomerUserProfile]', 'U'))
ALTER TABLE [dbo].[CustomerUserProfile] ADD CONSTRAINT [FK_CustomerUserProfile_UserProfileId] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Customer]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Warehouse]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [FK_Customer_Warehouse] FOREIGN KEY ([DefaultWarehouseId]) REFERENCES [dbo].[Warehouse] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Country]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [FK_Customer_Country] FOREIGN KEY ([CountryId]) REFERENCES [dbo].[Country] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [FK_Customer_Currency] FOREIGN KEY ([CurrencyId]) REFERENCES [dbo].[Currency] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_Salesperson]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [FK_Customer_Salesperson] FOREIGN KEY ([PrimarySalespersonId]) REFERENCES [dbo].[Salesperson] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Customer_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [FK_Customer_State] FOREIGN KEY ([StateId]) REFERENCES [dbo].[State] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PricingCustomer_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Customer]', 'U'))
ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [FK_PricingCustomer_Customer] FOREIGN KEY ([PricingCustomerId]) REFERENCES [dbo].[Customer] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[DashboardPanelPosition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DashboardPanelPosition_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DashboardPanelPosition]', 'U'))
ALTER TABLE [dbo].[DashboardPanelPosition] ADD CONSTRAINT [FK_DashboardPanelPosition_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[DealerCategory]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DealerCategory_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DealerCategory]', 'U'))
ALTER TABLE [dbo].[DealerCategory] ADD CONSTRAINT [FK_DealerCategory_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DealerCategory_Dealer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DealerCategory]', 'U'))
ALTER TABLE [dbo].[DealerCategory] ADD CONSTRAINT [FK_DealerCategory_Dealer] FOREIGN KEY ([DealerId]) REFERENCES [dbo].[Dealer] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[DealerProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DealerProduct_Dealer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DealerProduct]', 'U'))
ALTER TABLE [dbo].[DealerProduct] ADD CONSTRAINT [FK_DealerProduct_Dealer] FOREIGN KEY ([DealerId]) REFERENCES [dbo].[Dealer] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DealerProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DealerProduct]', 'U'))
ALTER TABLE [dbo].[DealerProduct] ADD CONSTRAINT [FK_DealerProduct_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[DealerProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DealerProperty_Dealer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[DealerProperty]', 'U'))
ALTER TABLE [dbo].[DealerProperty] ADD CONSTRAINT [FK_DealerProperty_Dealer] FOREIGN KEY ([DealerId]) REFERENCES [dbo].[Dealer] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Document]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Document_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Document]', 'U'))
ALTER TABLE [dbo].[Document] ADD CONSTRAINT [FK_Document_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Document_DocumentManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Document]', 'U'))
ALTER TABLE [dbo].[Document] ADD CONSTRAINT [FK_Document_DocumentManager] FOREIGN KEY ([DocumentManagerId]) REFERENCES [dbo].[DocumentManager] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[EmailList]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailList_EmailTemplate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailList]', 'U'))
ALTER TABLE [dbo].[EmailList] ADD CONSTRAINT [FK_EmailList_EmailTemplate] FOREIGN KEY ([EmailTemplateId]) REFERENCES [dbo].[EmailTemplate] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[EmailMessageAddress]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailMessageAddress_EmailMessage]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailMessageAddress]', 'U'))
ALTER TABLE [dbo].[EmailMessageAddress] ADD CONSTRAINT [FK_EmailMessageAddress_EmailMessage] FOREIGN KEY ([EmailMessageId]) REFERENCES [dbo].[EmailMessage] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[EmailMessageDeliveryAttempt]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailMessageDeliveryAttempt_EmailMessage]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailMessageDeliveryAttempt]', 'U'))
ALTER TABLE [dbo].[EmailMessageDeliveryAttempt] ADD CONSTRAINT [FK_EmailMessageDeliveryAttempt_EmailMessage] FOREIGN KEY ([EmailMessageId]) REFERENCES [dbo].[EmailMessage] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[EmailSubscriberEmailList]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailSubscriberEmailList_EmailList]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailSubscriberEmailList]', 'U'))
ALTER TABLE [dbo].[EmailSubscriberEmailList] ADD CONSTRAINT [FK_EmailSubscriberEmailList_EmailList] FOREIGN KEY ([EmailListId]) REFERENCES [dbo].[EmailList] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailSubscriberEmailList_EmailSubscriber]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailSubscriberEmailList]', 'U'))
ALTER TABLE [dbo].[EmailSubscriberEmailList] ADD CONSTRAINT [FK_EmailSubscriberEmailList_EmailSubscriber] FOREIGN KEY ([EmailSubscriberId]) REFERENCES [dbo].[EmailSubscriber] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[EmailTemplate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_EmailTemplate_ContentManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[EmailTemplate]', 'U'))
ALTER TABLE [dbo].[EmailTemplate] ADD CONSTRAINT [FK_EmailTemplate_ContentManager] FOREIGN KEY ([ContentManagerId]) REFERENCES [dbo].[ContentManager] ([Id]) ON DELETE SET NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[GiftCardTransaction]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_GiftCardTransaction_GiftCard]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[GiftCardTransaction]', 'U'))
ALTER TABLE [dbo].[GiftCardTransaction] ADD CONSTRAINT [FK_GiftCardTransaction_GiftCard] FOREIGN KEY ([GiftCardId]) REFERENCES [dbo].[GiftCard] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[GiftCard]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_GiftCard_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[GiftCard]', 'U'))
ALTER TABLE [dbo].[GiftCard] ADD CONSTRAINT [FK_GiftCard_Currency] FOREIGN KEY ([CurrencyId]) REFERENCES [dbo].[Currency] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_GiftCard_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[GiftCard]', 'U'))
ALTER TABLE [dbo].[GiftCard] ADD CONSTRAINT [FK_GiftCard_OrderLine] FOREIGN KEY ([OrderLineId]) REFERENCES [dbo].[OrderLine] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[GlobalSynonym]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_GlobalSynonym_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[GlobalSynonym]', 'U'))
ALTER TABLE [dbo].[GlobalSynonym] ADD CONSTRAINT [FK_GlobalSynonym_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[IntegrationJobLog]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobLog_IntegrationJob]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationJobLog]', 'U'))
ALTER TABLE [dbo].[IntegrationJobLog] ADD CONSTRAINT [FK_IntegrationJobLog_IntegrationJob] FOREIGN KEY ([IntegrationJobId]) REFERENCES [dbo].[IntegrationJob] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[IntegrationJobParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobParameter_IntegrationJob]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationJobParameter]', 'U'))
ALTER TABLE [dbo].[IntegrationJobParameter] ADD CONSTRAINT [FK_IntegrationJobParameter_IntegrationJob] FOREIGN KEY ([IntegrationJobId]) REFERENCES [dbo].[IntegrationJob] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJobParameter_JobDefinitionStepParameter]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationJobParameter]', 'U'))
ALTER TABLE [dbo].[IntegrationJobParameter] ADD CONSTRAINT [FK_IntegrationJobParameter_JobDefinitionStepParameter] FOREIGN KEY ([JobDefinitionStepParameterId]) REFERENCES [dbo].[JobDefinitionStepParameter] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[IntegrationJob]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationJob_JobDefinition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationJob]', 'U'))
ALTER TABLE [dbo].[IntegrationJob] ADD CONSTRAINT [FK_IntegrationJob_JobDefinition] FOREIGN KEY ([JobDefinitionId]) REFERENCES [dbo].[JobDefinition] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[InvoiceHistoryLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_InvoiceHistoryLine_InvoiceHistory]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[InvoiceHistoryLine]', 'U'))
ALTER TABLE [dbo].[InvoiceHistoryLine] ADD CONSTRAINT [FK_InvoiceHistoryLine_InvoiceHistory] FOREIGN KEY ([InvoiceHistoryId]) REFERENCES [dbo].[InvoiceHistory] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[JobDefinitionParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobDefinitionParameter_JobDefinition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionParameter]', 'U'))
ALTER TABLE [dbo].[JobDefinitionParameter] ADD CONSTRAINT [FK_JobDefinitionParameter_JobDefinition] FOREIGN KEY ([JobDefinitionId]) REFERENCES [dbo].[JobDefinition] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[JobDefinitionStepFieldMap]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobDefinitionStepFieldMap_JobDefinitionStep]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepFieldMap]', 'U'))
ALTER TABLE [dbo].[JobDefinitionStepFieldMap] ADD CONSTRAINT [FK_JobDefinitionStepFieldMap_JobDefinitionStep] FOREIGN KEY ([JobDefinitionStepId]) REFERENCES [dbo].[JobDefinitionStep] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[JobDefinitionStepParameter]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobDefinitionStepParameter_JobDefinitionStep]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionStepParameter]', 'U'))
ALTER TABLE [dbo].[JobDefinitionStepParameter] ADD CONSTRAINT [FK_JobDefinitionStepParameter_JobDefinitionStep] FOREIGN KEY ([JobDefinitionStepId]) REFERENCES [dbo].[JobDefinitionStep] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[JobDefinitionStep]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobDefinitionStep_JobDefinition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinitionStep]', 'U'))
ALTER TABLE [dbo].[JobDefinitionStep] ADD CONSTRAINT [FK_JobDefinitionStep_JobDefinition] FOREIGN KEY ([JobDefinitionId]) REFERENCES [dbo].[JobDefinition] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[JobDefinition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobDefinition_JobDefinition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [FK_JobDefinition_JobDefinition] FOREIGN KEY ([LinkedJobId]) REFERENCES [dbo].[JobDefinition] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobDefinition_EmailTemplate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [FK_JobDefinition_EmailTemplate] FOREIGN KEY ([EmailTemplateId]) REFERENCES [dbo].[EmailTemplate] ([Id]) ON DELETE SET NULL
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_JobDefinition_IntegrationConnection]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[JobDefinition]', 'U'))
ALTER TABLE [dbo].[JobDefinition] ADD CONSTRAINT [FK_JobDefinition_IntegrationConnection] FOREIGN KEY ([IntegrationConnectionId]) REFERENCES [dbo].[IntegrationConnection] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[LocalTaxRateTaxExemption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_LocalTaxRateTaxExemption_LocalTaxRate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[LocalTaxRateTaxExemption]', 'U'))
ALTER TABLE [dbo].[LocalTaxRateTaxExemption] ADD CONSTRAINT [FK_LocalTaxRateTaxExemption_LocalTaxRate] FOREIGN KEY ([LocalTaxRateId]) REFERENCES [dbo].[LocalTaxRate] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_LocalTaxRateTaxExemption_TaxExemption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[LocalTaxRateTaxExemption]', 'U'))
ALTER TABLE [dbo].[LocalTaxRateTaxExemption] ADD CONSTRAINT [FK_LocalTaxRateTaxExemption_TaxExemption] FOREIGN KEY ([TaxExemptionId]) REFERENCES [dbo].[TaxExemption] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[MenuRole]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MenuRole_Menu]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MenuRole]', 'U'))
ALTER TABLE [dbo].[MenuRole] ADD CONSTRAINT [FK_MenuRole_Menu] FOREIGN KEY ([MenuId]) REFERENCES [dbo].[Menu] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Menu]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Menu_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Menu]', 'U'))
ALTER TABLE [dbo].[Menu] ADD CONSTRAINT [FK_Menu_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Menu_Menu]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Menu]', 'U'))
ALTER TABLE [dbo].[Menu] ADD CONSTRAINT [FK_Menu_Menu] FOREIGN KEY ([ParentId]) REFERENCES [dbo].[Menu] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[MessageAudit]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageAudit_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U'))
ALTER TABLE [dbo].[MessageAudit] ADD CONSTRAINT [FK_MessageAudit_CustomerOrder] FOREIGN KEY ([CustomerOrderId]) REFERENCES [dbo].[CustomerOrder] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageAudit_FromUserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U'))
ALTER TABLE [dbo].[MessageAudit] ADD CONSTRAINT [FK_MessageAudit_FromUserProfile] FOREIGN KEY ([FromUserProfileId]) REFERENCES [dbo].[UserProfile] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageAudit_Message]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U'))
ALTER TABLE [dbo].[MessageAudit] ADD CONSTRAINT [FK_MessageAudit_Message] FOREIGN KEY ([MessageId]) REFERENCES [dbo].[Message] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageAudit_ToUserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageAudit]', 'U'))
ALTER TABLE [dbo].[MessageAudit] ADD CONSTRAINT [FK_MessageAudit_ToUserProfile] FOREIGN KEY ([ToUserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[MessageStatus]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageStatus_Message]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageStatus]', 'U'))
ALTER TABLE [dbo].[MessageStatus] ADD CONSTRAINT [FK_MessageStatus_Message] FOREIGN KEY ([MessageId]) REFERENCES [dbo].[Message] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageStatus_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageStatus]', 'U'))
ALTER TABLE [dbo].[MessageStatus] ADD CONSTRAINT [FK_MessageStatus_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[MessageTarget]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MessageTarget_Message]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MessageTarget]', 'U'))
ALTER TABLE [dbo].[MessageTarget] ADD CONSTRAINT [FK_MessageTarget_Message] FOREIGN KEY ([MessageId]) REFERENCES [dbo].[Message] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Message]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Message_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Message]', 'U'))
ALTER TABLE [dbo].[Message] ADD CONSTRAINT [FK_Message_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[MiscellaneousCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MiscellaneousCode_MiscellaneousCode]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[MiscellaneousCode]', 'U'))
ALTER TABLE [dbo].[MiscellaneousCode] ADD CONSTRAINT [FK_MiscellaneousCode_MiscellaneousCode] FOREIGN KEY ([ParentId]) REFERENCES [dbo].[MiscellaneousCode] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[NewsArticle]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_NewsArticle_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[NewsArticle]', 'U'))
ALTER TABLE [dbo].[NewsArticle] ADD CONSTRAINT [FK_NewsArticle_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_NewsArticle_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[NewsArticle]', 'U'))
ALTER TABLE [dbo].[NewsArticle] ADD CONSTRAINT [FK_NewsArticle_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[OrderHistoryLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderHistoryLine_OrderHistory]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderHistoryLine]', 'U'))
ALTER TABLE [dbo].[OrderHistoryLine] ADD CONSTRAINT [FK_OrderHistoryLine_OrderHistory] FOREIGN KEY ([OrderHistoryId]) REFERENCES [dbo].[OrderHistory] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[OrderLineConfigurationValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineConfigurationValue_ConfigurationOption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineConfigurationValue]', 'U'))
ALTER TABLE [dbo].[OrderLineConfigurationValue] ADD CONSTRAINT [FK_OrderLineConfigurationValue_ConfigurationOption] FOREIGN KEY ([ConfigurationOptionId]) REFERENCES [dbo].[ConfigurationOption] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineConfigurationValue_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineConfigurationValue]', 'U'))
ALTER TABLE [dbo].[OrderLineConfigurationValue] ADD CONSTRAINT [FK_OrderLineConfigurationValue_OrderLine] FOREIGN KEY ([OrderLineId]) REFERENCES [dbo].[OrderLine] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[OrderLineProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineProperty_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineProperty]', 'U'))
ALTER TABLE [dbo].[OrderLineProperty] ADD CONSTRAINT [FK_OrderLineProperty_OrderLine] FOREIGN KEY ([OrderLineId]) REFERENCES [dbo].[OrderLine] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[OrderLineRequisition]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineRequisition_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]', 'U'))
ALTER TABLE [dbo].[OrderLineRequisition] ADD CONSTRAINT [FK_OrderLineRequisition_OrderLine] FOREIGN KEY ([OrderLineId]) REFERENCES [dbo].[OrderLine] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineRequisition_OrderLineRequisition]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]', 'U'))
ALTER TABLE [dbo].[OrderLineRequisition] ADD CONSTRAINT [FK_OrderLineRequisition_OrderLineRequisition] FOREIGN KEY ([Id]) REFERENCES [dbo].[OrderLineRequisition] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineRequisition_OriginalOrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]', 'U'))
ALTER TABLE [dbo].[OrderLineRequisition] ADD CONSTRAINT [FK_OrderLineRequisition_OriginalOrderLine] FOREIGN KEY ([OriginalOrderLineId]) REFERENCES [dbo].[OrderLine] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineRequisition_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRequisition]', 'U'))
ALTER TABLE [dbo].[OrderLineRequisition] ADD CONSTRAINT [FK_OrderLineRequisition_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[OrderLineRfq]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLineRfq_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLineRfq]', 'U'))
ALTER TABLE [dbo].[OrderLineRfq] ADD CONSTRAINT [FK_OrderLineRfq_OrderLine] FOREIGN KEY ([OrderLineId]) REFERENCES [dbo].[OrderLine] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[OrderLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLine_Warehouse]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] ADD CONSTRAINT [FK_OrderLine_Warehouse] FOREIGN KEY ([WarehouseId]) REFERENCES [dbo].[Warehouse] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLine_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] ADD CONSTRAINT [FK_OrderLine_CustomerOrder] FOREIGN KEY ([CustomerOrderId]) REFERENCES [dbo].[CustomerOrder] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLine_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] ADD CONSTRAINT [FK_OrderLine_OrderLine] FOREIGN KEY ([Id]) REFERENCES [dbo].[OrderLine] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLine_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] ADD CONSTRAINT [FK_OrderLine_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLine_PromotionResult]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] ADD CONSTRAINT [FK_OrderLine_PromotionResult] FOREIGN KEY ([PromotionResultId]) REFERENCES [dbo].[PromotionResult] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderLine_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderLine]', 'U'))
ALTER TABLE [dbo].[OrderLine] ADD CONSTRAINT [FK_OrderLine_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[OrderPromotionCode]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_OrderPromotionCode_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[OrderPromotionCode]', 'U'))
ALTER TABLE [dbo].[OrderPromotionCode] ADD CONSTRAINT [FK_OrderPromotionCode_CustomerOrder] FOREIGN KEY ([CustomerOrderId]) REFERENCES [dbo].[CustomerOrder] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Persona]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Persona_RuleManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Persona]', 'U'))
ALTER TABLE [dbo].[Persona] ADD CONSTRAINT [FK_Persona_RuleManager] FOREIGN KEY ([RuleManagerId]) REFERENCES [dbo].[RuleManager] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ProductProductCrossSell]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductProductCrossSell_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductProductCrossSell]', 'U'))
ALTER TABLE [dbo].[ProductProductCrossSell] ADD CONSTRAINT [FK_ProductProductCrossSell_Product] FOREIGN KEY ([CrossSellProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductProductCrossSell_Product1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductProductCrossSell]', 'U'))
ALTER TABLE [dbo].[ProductProductCrossSell] ADD CONSTRAINT [FK_ProductProductCrossSell_Product1] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ProductProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductProperty_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductProperty]', 'U'))
ALTER TABLE [dbo].[ProductProperty] ADD CONSTRAINT [FK_ProductProperty_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ProductRelatedProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductRelatedProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductRelatedProduct]', 'U'))
ALTER TABLE [dbo].[ProductRelatedProduct] ADD CONSTRAINT [FK_ProductRelatedProduct_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductRelatedProduct_RelatedProduct]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductRelatedProduct]', 'U'))
ALTER TABLE [dbo].[ProductRelatedProduct] ADD CONSTRAINT [FK_ProductRelatedProduct_RelatedProduct] FOREIGN KEY ([RelatedProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductRelatedProduct_MiscellaneousCode]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductRelatedProduct]', 'U'))
ALTER TABLE [dbo].[ProductRelatedProduct] ADD CONSTRAINT [FK_ProductRelatedProduct_MiscellaneousCode] FOREIGN KEY ([ProductRelationshipMiscId]) REFERENCES [dbo].[MiscellaneousCode] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ProductSpecification]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductSpecification_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductSpecification]', 'U'))
ALTER TABLE [dbo].[ProductSpecification] ADD CONSTRAINT [FK_ProductSpecification_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductSpecification_Specification]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductSpecification]', 'U'))
ALTER TABLE [dbo].[ProductSpecification] ADD CONSTRAINT [FK_ProductSpecification_Specification] FOREIGN KEY ([SpecificationId]) REFERENCES [dbo].[Specification] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ProductTaxExemption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductTaxExemption_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductTaxExemption]', 'U'))
ALTER TABLE [dbo].[ProductTaxExemption] ADD CONSTRAINT [FK_ProductTaxExemption_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductTaxExemption_TaxExemption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductTaxExemption]', 'U'))
ALTER TABLE [dbo].[ProductTaxExemption] ADD CONSTRAINT [FK_ProductTaxExemption_TaxExemption] FOREIGN KEY ([TaxExemptionId]) REFERENCES [dbo].[TaxExemption] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ProductUnitOfMeasure]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductUnitOfMeasure_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductUnitOfMeasure]', 'U'))
ALTER TABLE [dbo].[ProductUnitOfMeasure] ADD CONSTRAINT [FK_ProductUnitOfMeasure_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ProductWarehouse]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductWarehouse_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductWarehouse]', 'U'))
ALTER TABLE [dbo].[ProductWarehouse] ADD CONSTRAINT [FK_ProductWarehouse_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ProductWarehouse_Warehouse]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ProductWarehouse]', 'U'))
ALTER TABLE [dbo].[ProductWarehouse] ADD CONSTRAINT [FK_ProductWarehouse_Warehouse] FOREIGN KEY ([WarehouseId]) REFERENCES [dbo].[Warehouse] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Product]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_Configuration]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [FK_Product_Configuration] FOREIGN KEY ([ConfigurationId]) REFERENCES [dbo].[Configuration] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_ReplacementProduct]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [FK_Product_ReplacementProduct] FOREIGN KEY ([ReplacementProductId]) REFERENCES [dbo].[Product] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_RestrictionGroup]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Product]', 'U'))
ALTER TABLE [dbo].[Product] ADD CONSTRAINT [FK_Product_RestrictionGroup] FOREIGN KEY ([RestrictionGroupId]) REFERENCES [dbo].[RestrictionGroup] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PromotionResult]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionResult_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionResult]', 'U'))
ALTER TABLE [dbo].[PromotionResult] ADD CONSTRAINT [FK_PromotionResult_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionResult_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionResult]', 'U'))
ALTER TABLE [dbo].[PromotionResult] ADD CONSTRAINT [FK_PromotionResult_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionResult_Promotion]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionResult]', 'U'))
ALTER TABLE [dbo].[PromotionResult] ADD CONSTRAINT [FK_PromotionResult_Promotion] FOREIGN KEY ([PromotionId]) REFERENCES [dbo].[Promotion] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PromotionResult_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PromotionResult]', 'U'))
ALTER TABLE [dbo].[PromotionResult] ADD CONSTRAINT [FK_PromotionResult_ShipVia] FOREIGN KEY ([ShipViaId]) REFERENCES [dbo].[ShipVia] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PunchOutCustomerUserProfileMap]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutCustomerUserProfileMap_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutCustomerUserProfileMap]', 'U'))
ALTER TABLE [dbo].[PunchOutCustomerUserProfileMap] ADD CONSTRAINT [FK_PunchOutCustomerUserProfileMap_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutCustomerUserProfileMap_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutCustomerUserProfileMap]', 'U'))
ALTER TABLE [dbo].[PunchOutCustomerUserProfileMap] ADD CONSTRAINT [FK_PunchOutCustomerUserProfileMap_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PunchOutOrderRequestExtrinsic]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequestExtrinsic_PunchOutOrderRequest]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestExtrinsic]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestExtrinsic] ADD CONSTRAINT [FK_PunchOutOrderRequestExtrinsic_PunchOutOrderRequest] FOREIGN KEY ([PunchOutOrderRequestId]) REFERENCES [dbo].[PunchOutOrderRequest] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PunchOutOrderRequestMessage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequestMessage_PunchOutOrderRequestItemOut]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] ADD CONSTRAINT [FK_PunchOutOrderRequestMessage_PunchOutOrderRequestItemOut] FOREIGN KEY ([PunchOutOrderRequestItemOutId]) REFERENCES [dbo].[PunchOutOrderRequestItemOut] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequestMessage_PunchOutOrderRequest]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestMessage]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestMessage] ADD CONSTRAINT [FK_PunchOutOrderRequestMessage_PunchOutOrderRequest] FOREIGN KEY ([PunchOutOrderRequestId]) REFERENCES [dbo].[PunchOutOrderRequest] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PunchOutOrderRequestItemOut]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequestItemOut_OrderLine]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [FK_PunchOutOrderRequestItemOut_OrderLine] FOREIGN KEY ([OrderLineId]) REFERENCES [dbo].[OrderLine] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequestItemOut_PunchOutOrderRequest]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequestItemOut]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequestItemOut] ADD CONSTRAINT [FK_PunchOutOrderRequestItemOut_PunchOutOrderRequest] FOREIGN KEY ([PunchOutOrderRequestId]) REFERENCES [dbo].[PunchOutOrderRequest] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PunchOutOrderRequest]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequest_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [FK_PunchOutOrderRequest_CustomerOrder] FOREIGN KEY ([CustomerOrderId]) REFERENCES [dbo].[CustomerOrder] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequest_PunchOutSessionId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [FK_PunchOutOrderRequest_PunchOutSessionId] FOREIGN KEY ([PunchOutSessionId]) REFERENCES [dbo].[PunchOutSession] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutOrderRequest_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutOrderRequest]', 'U'))
ALTER TABLE [dbo].[PunchOutOrderRequest] ADD CONSTRAINT [FK_PunchOutOrderRequest_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PunchOutSessionAccess]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSessionAccess_PunchOutSession]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSessionAccess]', 'U'))
ALTER TABLE [dbo].[PunchOutSessionAccess] ADD CONSTRAINT [FK_PunchOutSessionAccess_PunchOutSession] FOREIGN KEY ([PunchOutSessionId]) REFERENCES [dbo].[PunchOutSession] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PunchOutSessionExtrinsic]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSessionExtrinsic_PunchOutSession]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSessionExtrinsic]', 'U'))
ALTER TABLE [dbo].[PunchOutSessionExtrinsic] ADD CONSTRAINT [FK_PunchOutSessionExtrinsic_PunchOutSession] FOREIGN KEY ([PunchOutSessionId]) REFERENCES [dbo].[PunchOutSession] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PunchOutSessionItemIn]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSessionItemIn_PunchOutSession]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSessionItemIn]', 'U'))
ALTER TABLE [dbo].[PunchOutSessionItemIn] ADD CONSTRAINT [FK_PunchOutSessionItemIn_PunchOutSession] FOREIGN KEY ([PunchOutSessionId]) REFERENCES [dbo].[PunchOutSession] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PunchOutSession]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSession_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSession]', 'U'))
ALTER TABLE [dbo].[PunchOutSession] ADD CONSTRAINT [FK_PunchOutSession_CustomerOrder] FOREIGN KEY ([CustomerOrderId]) REFERENCES [dbo].[CustomerOrder] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSession_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSession]', 'U'))
ALTER TABLE [dbo].[PunchOutSession] ADD CONSTRAINT [FK_PunchOutSession_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[PunchOutSetupRequest]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_PunchOutSetupRequest_PunchOutSession]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[PunchOutSetupRequest]', 'U'))
ALTER TABLE [dbo].[PunchOutSetupRequest] ADD CONSTRAINT [FK_PunchOutSetupRequest_PunchOutSession] FOREIGN KEY ([PunchOutSessionId]) REFERENCES [dbo].[PunchOutSession] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[RuleClause]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RuleClause_RuleManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleClause]', 'U'))
ALTER TABLE [dbo].[RuleClause] ADD CONSTRAINT [FK_RuleClause_RuleManager] FOREIGN KEY ([RuleManagerId]) REFERENCES [dbo].[RuleManager] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RuleClause_RuleTypeOption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleClause]', 'U'))
ALTER TABLE [dbo].[RuleClause] ADD CONSTRAINT [FK_RuleClause_RuleTypeOption] FOREIGN KEY ([RuleTypeOptionId]) REFERENCES [dbo].[RuleTypeOption] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[RuleManager]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RuleManager_RuleType]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleManager]', 'U'))
ALTER TABLE [dbo].[RuleManager] ADD CONSTRAINT [FK_RuleManager_RuleType] FOREIGN KEY ([RuleTypeId]) REFERENCES [dbo].[RuleType] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[RuleTypeOption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_RuleTypeOption_RuleType]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[RuleTypeOption]', 'U'))
ALTER TABLE [dbo].[RuleTypeOption] ADD CONSTRAINT [FK_RuleTypeOption_RuleType] FOREIGN KEY ([RuleTypeId]) REFERENCES [dbo].[RuleType] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Salesperson]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Salesperson_SalesManager]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [FK_Salesperson_SalesManager] FOREIGN KEY ([SalesManagerId]) REFERENCES [dbo].[Salesperson] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Salesperson_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Salesperson]', 'U'))
ALTER TABLE [dbo].[Salesperson] ADD CONSTRAINT [FK_Salesperson_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id]) ON DELETE SET NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[SearchSynonym]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SearchSynonym_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[SearchSynonym]', 'U'))
ALTER TABLE [dbo].[SearchSynonym] ADD CONSTRAINT [FK_SearchSynonym_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ShipCharge]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipCharge_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipCharge]', 'U'))
ALTER TABLE [dbo].[ShipCharge] ADD CONSTRAINT [FK_ShipCharge_Carrier] FOREIGN KEY ([CarrierId]) REFERENCES [dbo].[Carrier] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipCharge_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipCharge]', 'U'))
ALTER TABLE [dbo].[ShipCharge] ADD CONSTRAINT [FK_ShipCharge_ShipVia] FOREIGN KEY ([ShipViaId]) REFERENCES [dbo].[ShipVia] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ShipRate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRate_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRate]', 'U'))
ALTER TABLE [dbo].[ShipRate] ADD CONSTRAINT [FK_ShipRate_ShipVia] FOREIGN KEY ([ShipViaId]) REFERENCES [dbo].[ShipVia] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ShipRule]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] ADD CONSTRAINT [FK_ShipRule_Carrier] FOREIGN KEY ([CarrierId]) REFERENCES [dbo].[Carrier] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] ADD CONSTRAINT [FK_ShipRule_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_Country]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] ADD CONSTRAINT [FK_ShipRule_Country] FOREIGN KEY ([CountryId]) REFERENCES [dbo].[Country] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] ADD CONSTRAINT [FK_ShipRule_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] ADD CONSTRAINT [FK_ShipRule_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_ShipRate]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] ADD CONSTRAINT [FK_ShipRule_ShipRate] FOREIGN KEY ([ShipRateId]) REFERENCES [dbo].[ShipRate] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] ADD CONSTRAINT [FK_ShipRule_ShipVia] FOREIGN KEY ([ShipViaId]) REFERENCES [dbo].[ShipVia] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipRule_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipRule]', 'U'))
ALTER TABLE [dbo].[ShipRule] ADD CONSTRAINT [FK_ShipRule_State] FOREIGN KEY ([StateId]) REFERENCES [dbo].[State] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ShipVia]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipVia_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipVia]', 'U'))
ALTER TABLE [dbo].[ShipVia] ADD CONSTRAINT [FK_ShipVia_Carrier] FOREIGN KEY ([CarrierId]) REFERENCES [dbo].[Carrier] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ShipmentPackageLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipmentPackageLine_ShipmentPackage]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipmentPackageLine]', 'U'))
ALTER TABLE [dbo].[ShipmentPackageLine] ADD CONSTRAINT [FK_ShipmentPackageLine_ShipmentPackage] FOREIGN KEY ([ShipmentPackageId]) REFERENCES [dbo].[ShipmentPackage] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ShipmentPackage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShipmentPackage_Shipment]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShipmentPackage]', 'U'))
ALTER TABLE [dbo].[ShipmentPackage] ADD CONSTRAINT [FK_ShipmentPackage_Shipment] FOREIGN KEY ([ShipmentId]) REFERENCES [dbo].[Shipment] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[ShippingRestriction]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShippingRestriction_Category]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U'))
ALTER TABLE [dbo].[ShippingRestriction] ADD CONSTRAINT [FK_ShippingRestriction_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShippingRestriction_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U'))
ALTER TABLE [dbo].[ShippingRestriction] ADD CONSTRAINT [FK_ShippingRestriction_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_ShippingRestriction_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[ShippingRestriction]', 'U'))
ALTER TABLE [dbo].[ShippingRestriction] ADD CONSTRAINT [FK_ShippingRestriction_State] FOREIGN KEY ([StateId]) REFERENCES [dbo].[State] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[StateTaxExemption]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StateTaxExemption_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StateTaxExemption]', 'U'))
ALTER TABLE [dbo].[StateTaxExemption] ADD CONSTRAINT [FK_StateTaxExemption_State] FOREIGN KEY ([StateId]) REFERENCES [dbo].[State] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StateTaxExemption_TaxExemption]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StateTaxExemption]', 'U'))
ALTER TABLE [dbo].[StateTaxExemption] ADD CONSTRAINT [FK_StateTaxExemption_TaxExemption] FOREIGN KEY ([TaxExemptionId]) REFERENCES [dbo].[TaxExemption] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[StyleTraitValueProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StyleTraitValueProduct_Product1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StyleTraitValueProduct]', 'U'))
ALTER TABLE [dbo].[StyleTraitValueProduct] ADD CONSTRAINT [FK_StyleTraitValueProduct_Product1] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StyleTraitValueProduct_StyleTraitValue1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StyleTraitValueProduct]', 'U'))
ALTER TABLE [dbo].[StyleTraitValueProduct] ADD CONSTRAINT [FK_StyleTraitValueProduct_StyleTraitValue1] FOREIGN KEY ([StyleTraitValueId]) REFERENCES [dbo].[StyleTraitValue] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[StyleTraitValue]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StyleTraitValue_StyleTrait1]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StyleTraitValue]', 'U'))
ALTER TABLE [dbo].[StyleTraitValue] ADD CONSTRAINT [FK_StyleTraitValue_StyleTrait1] FOREIGN KEY ([StyleTraitId]) REFERENCES [dbo].[StyleTrait] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[StyleTrait]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_StyleTrait_StyleClass]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[StyleTrait]', 'U'))
ALTER TABLE [dbo].[StyleTrait] ADD CONSTRAINT [FK_StyleTrait_StyleClass] FOREIGN KEY ([StyleClassId]) REFERENCES [dbo].[StyleClass] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[SubscriptionLine]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SubscriptionLine_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[SubscriptionLine]', 'U'))
ALTER TABLE [dbo].[SubscriptionLine] ADD CONSTRAINT [FK_SubscriptionLine_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SubscriptionLine_Subscription]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[SubscriptionLine]', 'U'))
ALTER TABLE [dbo].[SubscriptionLine] ADD CONSTRAINT [FK_SubscriptionLine_Subscription] FOREIGN KEY ([SubscriptionId]) REFERENCES [dbo].[Subscription] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[SubscriptionProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SubscriptionProduct_ParentProduct]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[SubscriptionProduct]', 'U'))
ALTER TABLE [dbo].[SubscriptionProduct] ADD CONSTRAINT [FK_SubscriptionProduct_ParentProduct] FOREIGN KEY ([ParentProductId]) REFERENCES [dbo].[Product] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_SubscriptionProduct_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[SubscriptionProduct]', 'U'))
ALTER TABLE [dbo].[SubscriptionProduct] ADD CONSTRAINT [FK_SubscriptionProduct_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Subscription]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [FK_Subscription_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_CustomerOrder]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [FK_Subscription_CustomerOrder] FOREIGN KEY ([CustomerOrderId]) REFERENCES [dbo].[CustomerOrder] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [FK_Subscription_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_ShipTo]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [FK_Subscription_ShipTo] FOREIGN KEY ([ShipToId]) REFERENCES [dbo].[Customer] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_ShipVia]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [FK_Subscription_ShipVia] FOREIGN KEY ([ShipViaId]) REFERENCES [dbo].[ShipVia] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [FK_Subscription_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subscription_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Subscription]', 'U'))
ALTER TABLE [dbo].[Subscription] ADD CONSTRAINT [FK_Subscription_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[TranslationDictionary]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TranslationDictionary_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[TranslationDictionary]', 'U'))
ALTER TABLE [dbo].[TranslationDictionary] ADD CONSTRAINT [FK_TranslationDictionary_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[TranslationProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_TranslationProperty_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[TranslationProperty]', 'U'))
ALTER TABLE [dbo].[TranslationProperty] ADD CONSTRAINT [FK_TranslationProperty_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[UserPaymentProfile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserPaymentProfile_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserPaymentProfile]', 'U'))
ALTER TABLE [dbo].[UserPaymentProfile] ADD CONSTRAINT [FK_UserPaymentProfile_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[UserProfileEmailList]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfileEmailList_EmailList]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfileEmailList]', 'U'))
ALTER TABLE [dbo].[UserProfileEmailList] ADD CONSTRAINT [FK_UserProfileEmailList_EmailList] FOREIGN KEY ([EmailListId]) REFERENCES [dbo].[EmailList] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfileEmailList_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfileEmailList]', 'U'))
ALTER TABLE [dbo].[UserProfileEmailList] ADD CONSTRAINT [FK_UserProfileEmailList_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[UserProfilePassword]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfilePassword_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfilePassword]', 'U'))
ALTER TABLE [dbo].[UserProfilePassword] ADD CONSTRAINT [FK_UserProfilePassword_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[UserProfileProperty]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfileProperty_UserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfileProperty]', 'U'))
ALTER TABLE [dbo].[UserProfileProperty] ADD CONSTRAINT [FK_UserProfileProperty_UserProfile] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[UserProfile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfile_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [FK_UserProfile_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfile_ApproverUserProfile]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [FK_UserProfile_ApproverUserProfile] FOREIGN KEY ([ApproverUserProfileId]) REFERENCES [dbo].[UserProfile] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfile_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [FK_UserProfile_Currency] FOREIGN KEY ([CurrencyId]) REFERENCES [dbo].[Currency] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfile_DefaultCustomer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[UserProfile]', 'U'))
ALTER TABLE [dbo].[UserProfile] ADD CONSTRAINT [FK_UserProfile_DefaultCustomer] FOREIGN KEY ([DefaultCustomerId]) REFERENCES [dbo].[Customer] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Vendor]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Vendor_Country]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Vendor]', 'U'))
ALTER TABLE [dbo].[Vendor] ADD CONSTRAINT [FK_Vendor_Country] FOREIGN KEY ([CountryId]) REFERENCES [dbo].[Country] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WarehouseAlternate]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WarehouseAlternate_AlternateWarehouse]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WarehouseAlternate]', 'U'))
ALTER TABLE [dbo].[WarehouseAlternate] ADD CONSTRAINT [FK_WarehouseAlternate_AlternateWarehouse] FOREIGN KEY ([AlternateWarehouseId]) REFERENCES [dbo].[Warehouse] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WarehouseAlternate_Warehouse]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WarehouseAlternate]', 'U'))
ALTER TABLE [dbo].[WarehouseAlternate] ADD CONSTRAINT [FK_WarehouseAlternate_Warehouse] FOREIGN KEY ([WarehouseId]) REFERENCES [dbo].[Warehouse] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[Warehouse]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Warehouse_Country]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[Warehouse]', 'U'))
ALTER TABLE [dbo].[Warehouse] ADD CONSTRAINT [FK_Warehouse_Country] FOREIGN KEY ([CountryId]) REFERENCES [dbo].[Country] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebPageContent]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebPageContent_WebPage]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebPageContent]', 'U'))
ALTER TABLE [dbo].[WebPageContent] ADD CONSTRAINT [FK_WebPageContent_WebPage] FOREIGN KEY ([WebPageId]) REFERENCES [dbo].[WebPage] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebPageContent_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebPageContent]', 'U'))
ALTER TABLE [dbo].[WebPageContent] ADD CONSTRAINT [FK_WebPageContent_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebPage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebPage_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebPage]', 'U'))
ALTER TABLE [dbo].[WebPage] ADD CONSTRAINT [FK_WebPage_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebSiteAllowedCustomers]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteAllowedCustomers_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteAllowedCustomers]', 'U'))
ALTER TABLE [dbo].[WebSiteAllowedCustomers] ADD CONSTRAINT [FK_WebSiteAllowedCustomers_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteAllowedCustomers_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteAllowedCustomers]', 'U'))
ALTER TABLE [dbo].[WebSiteAllowedCustomers] ADD CONSTRAINT [FK_WebSiteAllowedCustomers_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebSiteCarrier]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCarrier_Carrier]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCarrier]', 'U'))
ALTER TABLE [dbo].[WebSiteCarrier] ADD CONSTRAINT [FK_WebSiteCarrier_Carrier] FOREIGN KEY ([CarrierId]) REFERENCES [dbo].[Carrier] ([Id])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCarrier_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCarrier]', 'U'))
ALTER TABLE [dbo].[WebSiteCarrier] ADD CONSTRAINT [FK_WebSiteCarrier_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebSiteConfiguration]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteConfiguration_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteConfiguration]', 'U'))
ALTER TABLE [dbo].[WebSiteConfiguration] ADD CONSTRAINT [FK_WebSiteConfiguration_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebSiteCountry]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCountry_Country]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCountry]', 'U'))
ALTER TABLE [dbo].[WebSiteCountry] ADD CONSTRAINT [FK_WebSiteCountry_Country] FOREIGN KEY ([CountryId]) REFERENCES [dbo].[Country] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCountry_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCountry]', 'U'))
ALTER TABLE [dbo].[WebSiteCountry] ADD CONSTRAINT [FK_WebSiteCountry_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebSiteCurrency]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCurrency_Currency]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCurrency]', 'U'))
ALTER TABLE [dbo].[WebSiteCurrency] ADD CONSTRAINT [FK_WebSiteCurrency_Currency] FOREIGN KEY ([CurrencyId]) REFERENCES [dbo].[Currency] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteCurrency_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteCurrency]', 'U'))
ALTER TABLE [dbo].[WebSiteCurrency] ADD CONSTRAINT [FK_WebSiteCurrency_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebSiteDealer]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteDealer_Dealer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteDealer]', 'U'))
ALTER TABLE [dbo].[WebSiteDealer] ADD CONSTRAINT [FK_WebSiteDealer_Dealer] FOREIGN KEY ([DealerId]) REFERENCES [dbo].[Dealer] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteDealer_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteDealer]', 'U'))
ALTER TABLE [dbo].[WebSiteDealer] ADD CONSTRAINT [FK_WebSiteDealer_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebSiteLanguage]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteLanguage_Language]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteLanguage]', 'U'))
ALTER TABLE [dbo].[WebSiteLanguage] ADD CONSTRAINT [FK_WebSiteLanguage_Language] FOREIGN KEY ([LanguageId]) REFERENCES [dbo].[Language] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteLanguage_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteLanguage]', 'U'))
ALTER TABLE [dbo].[WebSiteLanguage] ADD CONSTRAINT [FK_WebSiteLanguage_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebSiteProductCrossSell]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteProductCrossSell_Product]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteProductCrossSell]', 'U'))
ALTER TABLE [dbo].[WebSiteProductCrossSell] ADD CONSTRAINT [FK_WebSiteProductCrossSell_Product] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteProductCrossSell_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteProductCrossSell]', 'U'))
ALTER TABLE [dbo].[WebSiteProductCrossSell] ADD CONSTRAINT [FK_WebSiteProductCrossSell_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebSitePromotion]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSitePromotion_Promotion]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSitePromotion]', 'U'))
ALTER TABLE [dbo].[WebSitePromotion] ADD CONSTRAINT [FK_WebSitePromotion_Promotion] FOREIGN KEY ([PromotionId]) REFERENCES [dbo].[Promotion] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSitePromotion_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSitePromotion]', 'U'))
ALTER TABLE [dbo].[WebSitePromotion] ADD CONSTRAINT [FK_WebSitePromotion_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WebSiteState]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteState_State]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteState]', 'U'))
ALTER TABLE [dbo].[WebSiteState] ADD CONSTRAINT [FK_WebSiteState_State] FOREIGN KEY ([StateId]) REFERENCES [dbo].[State] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WebSiteState_WebSite]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WebSiteState]', 'U'))
ALTER TABLE [dbo].[WebSiteState] ADD CONSTRAINT [FK_WebSiteState_WebSite] FOREIGN KEY ([WebSiteId]) REFERENCES [dbo].[WebSite] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WishListProduct]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Product_Id]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WishListProduct]', 'U'))
ALTER TABLE [dbo].[WishListProduct] ADD CONSTRAINT [FK_Product_Id] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Product] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WishList_Id]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WishListProduct]', 'U'))
ALTER TABLE [dbo].[WishListProduct] ADD CONSTRAINT [FK_WishList_Id] FOREIGN KEY ([WishListId]) REFERENCES [dbo].[WishList] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[WishList]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_UserProfileId]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WishList]', 'U'))
ALTER TABLE [dbo].[WishList] ADD CONSTRAINT [FK_UserProfileId] FOREIGN KEY ([UserProfileId]) REFERENCES [dbo].[UserProfile] ([Id]) ON DELETE CASCADE
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_WishList_Customer]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[WishList]', 'U'))
ALTER TABLE [dbo].[WishList] ADD CONSTRAINT [FK_WishList_Customer] FOREIGN KEY ([CustomerId]) REFERENCES [dbo].[Customer] ([Id]) ON DELETE CASCADE
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[aspnet_Membership]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Me__Appli__3C34F16F]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Membership]', 'U'))
ALTER TABLE [dbo].[aspnet_Membership] ADD CONSTRAINT [FK__aspnet_Me__Appli__3C34F16F] FOREIGN KEY ([ApplicationId]) REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Me__UserI__3D2915A8]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Membership]', 'U'))
ALTER TABLE [dbo].[aspnet_Membership] ADD CONSTRAINT [FK__aspnet_Me__UserI__3D2915A8] FOREIGN KEY ([UserId]) REFERENCES [dbo].[aspnet_Users] ([UserId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[aspnet_Paths]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pa__Appli__6DCC4D03]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Paths]', 'U'))
ALTER TABLE [dbo].[aspnet_Paths] ADD CONSTRAINT [FK__aspnet_Pa__Appli__6DCC4D03] FOREIGN KEY ([ApplicationId]) REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[aspnet_Roles]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Ro__Appli__5AB9788F]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Roles]', 'U'))
ALTER TABLE [dbo].[aspnet_Roles] ADD CONSTRAINT [FK__aspnet_Ro__Appli__5AB9788F] FOREIGN KEY ([ApplicationId]) REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[aspnet_Users]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Us__Appli__2BFE89A6]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Users]', 'U'))
ALTER TABLE [dbo].[aspnet_Users] ADD CONSTRAINT [FK__aspnet_Us__Appli__2BFE89A6] FOREIGN KEY ([ApplicationId]) REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[aspnet_PersonalizationPerUser]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pe__PathI__7755B73D]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser]', 'U'))
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] ADD CONSTRAINT [FK__aspnet_Pe__PathI__7755B73D] FOREIGN KEY ([PathId]) REFERENCES [dbo].[aspnet_Paths] ([PathId])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pe__UserI__7849DB76]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_PersonalizationPerUser]', 'U'))
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser] ADD CONSTRAINT [FK__aspnet_Pe__UserI__7849DB76] FOREIGN KEY ([UserId]) REFERENCES [dbo].[aspnet_Users] ([UserId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[aspnet_PersonalizationAllUsers]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pe__PathI__73852659]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_PersonalizationAllUsers]', 'U'))
ALTER TABLE [dbo].[aspnet_PersonalizationAllUsers] ADD CONSTRAINT [FK__aspnet_Pe__PathI__73852659] FOREIGN KEY ([PathId]) REFERENCES [dbo].[aspnet_Paths] ([PathId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[aspnet_UsersInRoles]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Us__RoleI__5F7E2DAC]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_UsersInRoles]', 'U'))
ALTER TABLE [dbo].[aspnet_UsersInRoles] ADD CONSTRAINT [FK__aspnet_Us__RoleI__5F7E2DAC] FOREIGN KEY ([RoleId]) REFERENCES [dbo].[aspnet_Roles] ([RoleId])
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Us__UserI__5E8A0973]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_UsersInRoles]', 'U'))
ALTER TABLE [dbo].[aspnet_UsersInRoles] ADD CONSTRAINT [FK__aspnet_Us__UserI__5E8A0973] FOREIGN KEY ([UserId]) REFERENCES [dbo].[aspnet_Users] ([UserId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Adding foreign keys to [dbo].[aspnet_Profile]'
GO
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__aspnet_Pr__UserI__51300E55]', 'F') AND parent_object_id = OBJECT_ID(N'[dbo].[aspnet_Profile]', 'U'))
ALTER TABLE [dbo].[aspnet_Profile] ADD CONSTRAINT [FK__aspnet_Pr__UserI__51300E55] FOREIGN KEY ([UserId]) REFERENCES [dbo].[aspnet_Users] ([UserId])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating extended properties'
GO
IF NOT EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_Description', 'SCHEMA', N'dbo', 'TABLE', N'CategoryAttributeType', 'COLUMN', N'DetailDisplaySequence'))
EXEC sp_addextendedproperty N'MS_Description', N'Intentionally set to null - only if there is a value will it display in the Product Detail Page', 'SCHEMA', N'dbo', 'TABLE', N'CategoryAttributeType', 'COLUMN', N'DetailDisplaySequence'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_Description', 'SCHEMA', N'dbo', 'TABLE', N'DictionaryAttribute', 'COLUMN', N'DisplayType'))
EXEC sp_addextendedproperty N'MS_Description', N'0 = hidden, 1 = visible, 2 = enabled', 'SCHEMA', N'dbo', 'TABLE', N'DictionaryAttribute', 'COLUMN', N'DisplayType'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_DiagramPane1', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryLineView', NULL, NULL))
EXEC sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryLineView', NULL, NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
DECLARE @xp int
SELECT @xp=1
IF NOT EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_DiagramPaneCount', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryLineView', NULL, NULL))
EXEC sp_addextendedproperty N'MS_DiagramPaneCount', @xp, 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryLineView', NULL, NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
IF NOT EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_DiagramPane1', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryView', NULL, NULL))
EXEC sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1 [50] 2 [25] 3))"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = -576
         Left = 0
      End
      Begin Tables = 
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryView', NULL, NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
DECLARE @xp int
SELECT @xp=1
IF NOT EXISTS (SELECT 1 FROM fn_listextendedproperty(N'MS_DiagramPaneCount', 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryView', NULL, NULL))
EXEC sp_addextendedproperty N'MS_DiagramPaneCount', @xp, 'SCHEMA', N'dbo', 'VIEW', N'ReportOrderHistoryView', NULL, NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
COMMIT TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
DECLARE @Success AS BIT
SET @Success = 1
SET NOEXEC OFF
IF (@Success = 1) PRINT 'The database update succeeded'
ELSE BEGIN
	IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
	PRINT 'The database update failed'
END
GO
