Deleting All Data from a SQL Server Database: Listing 1

Use AdventureWorks

-- Drop Foreign Key Constraint [FK_StoreContact_Store_CustomerID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
			WHERE object_id = OBJECT_ID(N'[Sales].[FK_StoreContact_Store_CustomerID]') AND
				  parent_object_id = 
				  OBJECT_ID('[Sales].[StoreContact]')) BEGIN 
    ALTER TABLE [SALES].[STORECONTACT] 
               DROP CONSTRAINT [FK_StoreContact_Store_CustomerID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_StoreContact_Store_CustomerID]'
END
GO

-- Drop Foreign Key Constraint [FK_StoreContact_Contact_ContactID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id = OBJECT_ID(N'[Sales].[FK_StoreContact_Contact_ContactID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[StoreContact]')) BEGIN 
    ALTER TABLE [SALES].[STORECONTACT] 
               DROP CONSTRAINT [FK_StoreContact_Contact_ContactID]
    Print 'Dropped Foreign Key Constraint [FK_StoreContact_Contact_ContactID]'
END
GO

-- Drop Foreign Key Constraint [FK_StoreContact_ContactType_ContactTypeID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_StoreContact_ContactType_ContactTypeID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[StoreContact]')) BEGIN 
    ALTER TABLE [SALES].[STORECONTACT] 
               DROP CONSTRAINT [FK_StoreContact_ContactType_ContactTypeID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_StoreContact_ContactType_ContactTypeID]'
END
GO

-- Drop Foreign Key Constraint [FK_Store_SalesPerson_SalesPersonID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_Store_SalesPerson_SalesPersonID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[Store]')) BEGIN 
    ALTER TABLE [SALES].[STORE] 
               DROP CONSTRAINT [FK_Store_SalesPerson_SalesPersonID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Store_SalesPerson_SalesPersonID]'
END
GO

-- Drop Foreign Key Constraint [FK_Store_Customer_CustomerID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_Store_Customer_CustomerID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[Store]')) BEGIN 
    ALTER TABLE [SALES].[STORE] 
               DROP CONSTRAINT [FK_Store_Customer_CustomerID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Store_Customer_CustomerID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesTerritoryHistory_SalesPerson_SalesPersonID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesTerritoryHistory_SalesPerson_SalesPersonID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesTerritoryHistory]')) BEGIN 
    ALTER TABLE [SALES].[SALESTERRITORYHISTORY] 
               DROP CONSTRAINT [FK_SalesTerritoryHistory_SalesPerson_SalesPersonID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesTerritoryHistory_SalesPerson_SalesPersonID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesTerritoryHistory_SalesTerritory_TerritoryID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesTerritoryHistory_SalesTerritory_TerritoryID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesTerritoryHistory]')) BEGIN 
    ALTER TABLE [SALES].[SALESTERRITORYHISTORY] 
               DROP CONSTRAINT [FK_SalesTerritoryHistory_SalesTerritory_TerritoryID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesTerritoryHistory_SalesTerritory_TerritoryID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesPersonQuotaHistory]')) BEGIN 
    ALTER TABLE [SALES].[SALESPERSONQUOTAHISTORY] 
               DROP CONSTRAINT [FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderHeaderSalesReason]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERHEADERSALESREASON] 
               DROP CONSTRAINT [FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderHeaderSalesReason]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERHEADERSALESREASON] 
               DROP CONSTRAINT [FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderDetail]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERDETAIL] 
               DROP CONSTRAINT [FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderDetail]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERDETAIL] 
               DROP CONSTRAINT [FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderHeader_SalesPerson_SalesPersonID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderHeader_SalesPerson_SalesPersonID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderHeader]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
               DROP CONSTRAINT [FK_SalesOrderHeader_SalesPerson_SalesPersonID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderHeader_SalesPerson_SalesPersonID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderHeader_Address_ShipToAddressID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderHeader_Address_ShipToAddressID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderHeader]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
               DROP CONSTRAINT [FK_SalesOrderHeader_Address_ShipToAddressID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderHeader_Address_ShipToAddressID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderHeader_Address_BillToAddressID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderHeader_Address_BillToAddressID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderHeader]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
               DROP CONSTRAINT [FK_SalesOrderHeader_Address_BillToAddressID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderHeader_Address_BillToAddressID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderHeader_CurrencyRate_CurrencyRateID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderHeader_CurrencyRate_CurrencyRateID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderHeader]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
               DROP CONSTRAINT [FK_SalesOrderHeader_CurrencyRate_CurrencyRateID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderHeader_CurrencyRate_CurrencyRateID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderHeader_Customer_CustomerID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderHeader_Customer_CustomerID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderHeader]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
               DROP CONSTRAINT [FK_SalesOrderHeader_Customer_CustomerID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderHeader_Customer_CustomerID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderHeader_Contact_ContactID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderHeader_Contact_ContactID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderHeader]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
               DROP CONSTRAINT [FK_SalesOrderHeader_Contact_ContactID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderHeader_Contact_ContactID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderHeader_CreditCard_CreditCardID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderHeader_CreditCard_CreditCardID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderHeader]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
               DROP CONSTRAINT [FK_SalesOrderHeader_CreditCard_CreditCardID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderHeader_CreditCard_CreditCardID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderHeader_SalesTerritory_TerritoryID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderHeader_SalesTerritory_TerritoryID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderHeader]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
               DROP CONSTRAINT [FK_SalesOrderHeader_SalesTerritory_TerritoryID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderHeader_SalesTerritory_TerritoryID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesOrderHeader_ShipMethod_ShipMethodID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesOrderHeader_ShipMethod_ShipMethodID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesOrderHeader]')) BEGIN 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
               DROP CONSTRAINT [FK_SalesOrderHeader_ShipMethod_ShipMethodID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesOrderHeader_ShipMethod_ShipMethodID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesPerson_Employee_SalesPersonID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesPerson_Employee_SalesPersonID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesPerson]')) BEGIN 
    ALTER TABLE [SALES].[SALESPERSON] 
               DROP CONSTRAINT [FK_SalesPerson_Employee_SalesPersonID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesPerson_Employee_SalesPersonID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesPerson_SalesTerritory_TerritoryID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesPerson_SalesTerritory_TerritoryID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesPerson]')) BEGIN 
    ALTER TABLE [SALES].[SALESPERSON] 
               DROP CONSTRAINT [FK_SalesPerson_SalesTerritory_TerritoryID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesPerson_SalesTerritory_TerritoryID]'
END
GO

-- Drop Foreign Key Constraint [FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[PurchaseOrderDetail]')) BEGIN 
    ALTER TABLE [PURCHASING].[PURCHASEORDERDETAIL] 
               DROP CONSTRAINT [FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID]'
END
GO

-- Drop Foreign Key Constraint [FK_PurchaseOrderDetail_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_PurchaseOrderDetail_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[PurchaseOrderDetail]')) BEGIN 
    ALTER TABLE [PURCHASING].[PURCHASEORDERDETAIL] 
               DROP CONSTRAINT [FK_PurchaseOrderDetail_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_PurchaseOrderDetail_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_PurchaseOrderHeader_Employee_EmployeeID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_PurchaseOrderHeader_Employee_EmployeeID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[PurchaseOrderHeader]')) BEGIN 
    ALTER TABLE [PURCHASING].[PURCHASEORDERHEADER] 
               DROP CONSTRAINT [FK_PurchaseOrderHeader_Employee_EmployeeID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_PurchaseOrderHeader_Employee_EmployeeID]'
END
GO

-- Drop Foreign Key Constraint [FK_PurchaseOrderHeader_ShipMethod_ShipMethodID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_PurchaseOrderHeader_ShipMethod_ShipMethodID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[PurchaseOrderHeader]')) BEGIN 
    ALTER TABLE [PURCHASING].[PURCHASEORDERHEADER] 
               DROP CONSTRAINT [FK_PurchaseOrderHeader_ShipMethod_ShipMethodID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_PurchaseOrderHeader_ShipMethod_ShipMethodID]'
END
GO

-- Drop Foreign Key Constraint [FK_PurchaseOrderHeader_Vendor_VendorID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_PurchaseOrderHeader_Vendor_VendorID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[PurchaseOrderHeader]')) BEGIN 
    ALTER TABLE [PURCHASING].[PURCHASEORDERHEADER] 
               DROP CONSTRAINT [FK_PurchaseOrderHeader_Vendor_VendorID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_PurchaseOrderHeader_Vendor_VendorID]'
END
GO

-- Drop Foreign Key Constraint [FK_JobCandidate_Employee_EmployeeID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[HumanResources].[FK_JobCandidate_Employee_EmployeeID]') 
                 AND parent_object_id =
                 OBJECT_ID('[HumanResources].[JobCandidate]')) BEGIN 
    ALTER TABLE [HUMANRESOURCES].[JOBCANDIDATE] 
               DROP CONSTRAINT [FK_JobCandidate_Employee_EmployeeID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_JobCandidate_Employee_EmployeeID]'
END
GO

-- Drop Foreign Key Constraint [FK_EmployeePayHistory_Employee_EmployeeID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[HumanResources].[FK_EmployeePayHistory_Employee_EmployeeID]') 
                 AND parent_object_id =
                 OBJECT_ID('[HumanResources].[EmployeePayHistory]')) BEGIN 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEPAYHISTORY] 
               DROP CONSTRAINT [FK_EmployeePayHistory_Employee_EmployeeID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_EmployeePayHistory_Employee_EmployeeID]'
END
GO

-- Drop Foreign Key Constraint [FK_EmployeeDepartmentHistory_Employee_EmployeeID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[HumanResources].[FK_EmployeeDepartmentHistory_Employee_EmployeeID]') 
                 AND parent_object_id =
                 OBJECT_ID('[HumanResources].[EmployeeDepartmentHistory]')) BEGIN 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEDEPARTMENTHISTORY] 
               DROP CONSTRAINT [FK_EmployeeDepartmentHistory_Employee_EmployeeID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_EmployeeDepartmentHistory_Employee_EmployeeID]'
END
GO

-- Drop Foreign Key Constraint [FK_EmployeeDepartmentHistory_Department_DepartmentID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[HumanResources].[FK_EmployeeDepartmentHistory_Department_DepartmentID]') 
                 AND parent_object_id =
                 OBJECT_ID('[HumanResources].[EmployeeDepartmentHistory]')) BEGIN 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEDEPARTMENTHISTORY] 
               DROP CONSTRAINT [FK_EmployeeDepartmentHistory_Department_DepartmentID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_EmployeeDepartmentHistory_Department_DepartmentID]'
END
GO

-- Drop Foreign Key Constraint [FK_EmployeeDepartmentHistory_Shift_ShiftID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[HumanResources].[FK_EmployeeDepartmentHistory_Shift_ShiftID]') 
                 AND parent_object_id =
                 OBJECT_ID('[HumanResources].[EmployeeDepartmentHistory]')) BEGIN 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEDEPARTMENTHISTORY] 
               DROP CONSTRAINT [FK_EmployeeDepartmentHistory_Shift_ShiftID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_EmployeeDepartmentHistory_Shift_ShiftID]'
END
GO

-- Drop Foreign Key Constraint [FK_EmployeeAddress_Employee_EmployeeID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[HumanResources].[FK_EmployeeAddress_Employee_EmployeeID]') 
                 AND parent_object_id =
                 OBJECT_ID('[HumanResources].[EmployeeAddress]')) BEGIN 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEADDRESS] 
               DROP CONSTRAINT [FK_EmployeeAddress_Employee_EmployeeID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_EmployeeAddress_Employee_EmployeeID]'
END
GO

-- Drop Foreign Key Constraint [FK_EmployeeAddress_Address_AddressID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[HumanResources].[FK_EmployeeAddress_Address_AddressID]') 
                 AND parent_object_id =
                 OBJECT_ID('[HumanResources].[EmployeeAddress]')) BEGIN 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEADDRESS] 
               DROP CONSTRAINT [FK_EmployeeAddress_Address_AddressID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_EmployeeAddress_Address_AddressID]'
END
GO

-- Drop Foreign Key Constraint [FK_Employee_Employee_ManagerID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[HumanResources].[FK_Employee_Employee_ManagerID]') 
                 AND parent_object_id =
                 OBJECT_ID('[HumanResources].[Employee]')) BEGIN 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEE] 
               DROP CONSTRAINT [FK_Employee_Employee_ManagerID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Employee_Employee_ManagerID]'
END
GO

-- Drop Foreign Key Constraint [FK_Employee_Contact_ContactID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[HumanResources].[FK_Employee_Contact_ContactID]') 
                 AND parent_object_id =
                 OBJECT_ID('[HumanResources].[Employee]')) BEGIN 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEE] 
               DROP CONSTRAINT [FK_Employee_Contact_ContactID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Employee_Contact_ContactID]'
END
GO

-- Drop Foreign Key Constraint [FK_CustomerAddress_Address_AddressID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_CustomerAddress_Address_AddressID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[CustomerAddress]')) BEGIN 
    ALTER TABLE [SALES].[CUSTOMERADDRESS] 
               DROP CONSTRAINT [FK_CustomerAddress_Address_AddressID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_CustomerAddress_Address_AddressID]'
END
GO

-- Drop Foreign Key Constraint [FK_CustomerAddress_Customer_CustomerID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_CustomerAddress_Customer_CustomerID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[CustomerAddress]')) BEGIN 
    ALTER TABLE [SALES].[CUSTOMERADDRESS] 
               DROP CONSTRAINT [FK_CustomerAddress_Customer_CustomerID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_CustomerAddress_Customer_CustomerID]'
END
GO

-- Drop Foreign Key Constraint [FK_CustomerAddress_AddressType_AddressTypeID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_CustomerAddress_AddressType_AddressTypeID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[CustomerAddress]')) BEGIN 
    ALTER TABLE [SALES].[CUSTOMERADDRESS] 
               DROP CONSTRAINT [FK_CustomerAddress_AddressType_AddressTypeID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_CustomerAddress_AddressType_AddressTypeID]'
END
GO

-- Drop Foreign Key Constraint [FK_VendorAddress_Address_AddressID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_VendorAddress_Address_AddressID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[VendorAddress]')) BEGIN 
    ALTER TABLE [PURCHASING].[VENDORADDRESS] 
               DROP CONSTRAINT [FK_VendorAddress_Address_AddressID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_VendorAddress_Address_AddressID]'
END
GO

-- Drop Foreign Key Constraint [FK_VendorAddress_AddressType_AddressTypeID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_VendorAddress_AddressType_AddressTypeID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[VendorAddress]')) BEGIN 
    ALTER TABLE [PURCHASING].[VENDORADDRESS] 
               DROP CONSTRAINT [FK_VendorAddress_AddressType_AddressTypeID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_VendorAddress_AddressType_AddressTypeID]'
END
GO

-- Drop Foreign Key Constraint [FK_VendorAddress_Vendor_VendorID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_VendorAddress_Vendor_VendorID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[VendorAddress]')) BEGIN 
    ALTER TABLE [PURCHASING].[VENDORADDRESS] 
               DROP CONSTRAINT [FK_VendorAddress_Vendor_VendorID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_VendorAddress_Vendor_VendorID]'
END
GO

-- Drop Foreign Key Constraint [FK_Address_StateProvince_StateProvinceID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Person].[FK_Address_StateProvince_StateProvinceID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Person].[Address]')) BEGIN 
    ALTER TABLE [PERSON].[ADDRESS] 
               DROP CONSTRAINT [FK_Address_StateProvince_StateProvinceID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Address_StateProvince_StateProvinceID]'
END
GO

-- Drop Foreign Key Constraint [FK_SalesTaxRate_StateProvince_StateProvinceID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SalesTaxRate_StateProvince_StateProvinceID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SalesTaxRate]')) BEGIN 
    ALTER TABLE [SALES].[SALESTAXRATE] 
               DROP CONSTRAINT [FK_SalesTaxRate_StateProvince_StateProvinceID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SalesTaxRate_StateProvince_StateProvinceID]'
END
GO

-- Drop Foreign Key Constraint [FK_StateProvince_CountryRegion_CountryRegionCode]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Person].[FK_StateProvince_CountryRegion_CountryRegionCode]') 
                 AND parent_object_id =
                 OBJECT_ID('[Person].[StateProvince]')) BEGIN 
    ALTER TABLE [PERSON].[STATEPROVINCE] 
               DROP CONSTRAINT [FK_StateProvince_CountryRegion_CountryRegionCode]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_StateProvince_CountryRegion_CountryRegionCode]'
END
GO

-- Drop Foreign Key Constraint [FK_StateProvince_SalesTerritory_TerritoryID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Person].[FK_StateProvince_SalesTerritory_TerritoryID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Person].[StateProvince]')) BEGIN 
    ALTER TABLE [PERSON].[STATEPROVINCE] 
               DROP CONSTRAINT [FK_StateProvince_SalesTerritory_TerritoryID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_StateProvince_SalesTerritory_TerritoryID]'
END
GO

-- Delete From [Person].[StateProvince]
BEGIN
    DELETE FROM [Person].[StateProvince]
    Print 'Deleted From [Person].[StateProvince]'
    DBCC CHECKIDENT ('[Person].[StateProvince]',RESEED,1)
    Print 'Reset Identity Seed To 1 for [Person].[StateProvince]'
END
GO

-- Drop Foreign Key Constraint [FK_BillOfMaterials_Product_ComponentID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_BillOfMaterials_Product_ComponentID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[BillOfMaterials]')) BEGIN 
    ALTER TABLE [PRODUCTION].[BILLOFMATERIALS] 
               DROP CONSTRAINT [FK_BillOfMaterials_Product_ComponentID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_BillOfMaterials_Product_ComponentID]'
END
GO

-- Drop Foreign Key Constraint [FK_BillOfMaterials_Product_ProductAssemblyID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_BillOfMaterials_Product_ProductAssemblyID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[BillOfMaterials]')) BEGIN 
    ALTER TABLE [PRODUCTION].[BILLOFMATERIALS] 
               DROP CONSTRAINT [FK_BillOfMaterials_Product_ProductAssemblyID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_BillOfMaterials_Product_ProductAssemblyID]'
END
GO

-- Drop Foreign Key Constraint [FK_BillOfMaterials_UnitMeasure_UnitMeasureCode]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_BillOfMaterials_UnitMeasure_UnitMeasureCode]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[BillOfMaterials]')) BEGIN 
    ALTER TABLE [PRODUCTION].[BILLOFMATERIALS] 
               DROP CONSTRAINT [FK_BillOfMaterials_UnitMeasure_UnitMeasureCode]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_BillOfMaterials_UnitMeasure_UnitMeasureCode]'
END
GO

-- Drop Foreign Key Constraint [FK_SpecialOfferProduct_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SpecialOfferProduct_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SpecialOfferProduct]')) BEGIN 
    ALTER TABLE [SALES].[SPECIALOFFERPRODUCT] 
               DROP CONSTRAINT [FK_SpecialOfferProduct_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SpecialOfferProduct_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_SpecialOfferProduct_SpecialOffer_SpecialOfferID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_SpecialOfferProduct_SpecialOffer_SpecialOfferID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[SpecialOfferProduct]')) BEGIN 
    ALTER TABLE [SALES].[SPECIALOFFERPRODUCT] 
               DROP CONSTRAINT [FK_SpecialOfferProduct_SpecialOffer_SpecialOfferID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_SpecialOfferProduct_SpecialOffer_SpecialOfferID]'
END
GO

-- Drop Foreign Key Constraint [FK_ShoppingCartItem_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_ShoppingCartItem_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[ShoppingCartItem]')) BEGIN 
    ALTER TABLE [SALES].[SHOPPINGCARTITEM] 
               DROP CONSTRAINT [FK_ShoppingCartItem_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ShoppingCartItem_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductVendor_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_ProductVendor_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[ProductVendor]')) BEGIN 
    ALTER TABLE [PURCHASING].[PRODUCTVENDOR] 
               DROP CONSTRAINT [FK_ProductVendor_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductVendor_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductVendor_UnitMeasure_UnitMeasureCode]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_ProductVendor_UnitMeasure_UnitMeasureCode]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[ProductVendor]')) BEGIN 
    ALTER TABLE [PURCHASING].[PRODUCTVENDOR] 
               DROP CONSTRAINT [FK_ProductVendor_UnitMeasure_UnitMeasureCode]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductVendor_UnitMeasure_UnitMeasureCode]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductVendor_Vendor_VendorID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_ProductVendor_Vendor_VendorID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[ProductVendor]')) BEGIN 
    ALTER TABLE [PURCHASING].[PRODUCTVENDOR] 
               DROP CONSTRAINT [FK_ProductVendor_Vendor_VendorID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductVendor_Vendor_VendorID]'
END
GO

-- Drop Foreign Key Constraint [FK_WorkOrderRouting_WorkOrder_WorkOrderID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_WorkOrderRouting_WorkOrder_WorkOrderID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[WorkOrderRouting]')) BEGIN 
    ALTER TABLE [PRODUCTION].[WORKORDERROUTING] 
               DROP CONSTRAINT [FK_WorkOrderRouting_WorkOrder_WorkOrderID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_WorkOrderRouting_WorkOrder_WorkOrderID]'
END
GO

-- Drop Foreign Key Constraint [FK_WorkOrderRouting_Location_LocationID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_WorkOrderRouting_Location_LocationID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[WorkOrderRouting]')) BEGIN 
    ALTER TABLE [PRODUCTION].[WORKORDERROUTING] 
               DROP CONSTRAINT [FK_WorkOrderRouting_Location_LocationID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_WorkOrderRouting_Location_LocationID]'
END
GO

-- Drop Foreign Key Constraint [FK_WorkOrder_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_WorkOrder_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[WorkOrder]')) BEGIN 
    ALTER TABLE [PRODUCTION].[WORKORDER] 
               DROP CONSTRAINT [FK_WorkOrder_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_WorkOrder_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_WorkOrder_ScrapReason_ScrapReasonID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_WorkOrder_ScrapReason_ScrapReasonID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[WorkOrder]')) BEGIN 
    ALTER TABLE [PRODUCTION].[WORKORDER] 
               DROP CONSTRAINT [FK_WorkOrder_ScrapReason_ScrapReasonID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_WorkOrder_ScrapReason_ScrapReasonID]'
END
GO

-- Drop Foreign Key Constraint [FK_TransactionHistory_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_TransactionHistory_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[TransactionHistory]')) BEGIN 
    ALTER TABLE [PRODUCTION].[TRANSACTIONHISTORY] 
               DROP CONSTRAINT [FK_TransactionHistory_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_TransactionHistory_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductReview_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductReview_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductReview]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTREVIEW] 
               DROP CONSTRAINT [FK_ProductReview_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductReview_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductProductPhoto_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductProductPhoto_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductProductPhoto]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTPRODUCTPHOTO] 
               DROP CONSTRAINT [FK_ProductProductPhoto_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductProductPhoto_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductProductPhoto_ProductPhoto_ProductPhotoID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductProductPhoto_ProductPhoto_ProductPhotoID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductProductPhoto]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTPRODUCTPHOTO] 
               DROP CONSTRAINT [FK_ProductProductPhoto_ProductPhoto_ProductPhotoID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductProductPhoto_ProductPhoto_ProductPhotoID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductListPriceHistory_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductListPriceHistory_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductListPriceHistory]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTLISTPRICEHISTORY] 
               DROP CONSTRAINT [FK_ProductListPriceHistory_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductListPriceHistory_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductInventory_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductInventory_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductInventory]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTINVENTORY] 
               DROP CONSTRAINT [FK_ProductInventory_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductInventory_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductInventory_Location_LocationID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductInventory_Location_LocationID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductInventory]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTINVENTORY] 
               DROP CONSTRAINT [FK_ProductInventory_Location_LocationID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductInventory_Location_LocationID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductDocument_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductDocument_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductDocument]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTDOCUMENT] 
               DROP CONSTRAINT [FK_ProductDocument_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductDocument_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductDocument_Document_DocumentID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductDocument_Document_DocumentID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductDocument]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTDOCUMENT] 
               DROP CONSTRAINT [FK_ProductDocument_Document_DocumentID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductDocument_Document_DocumentID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductCostHistory_Product_ProductID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductCostHistory_Product_ProductID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductCostHistory]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTCOSTHISTORY] 
               DROP CONSTRAINT [FK_ProductCostHistory_Product_ProductID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductCostHistory_Product_ProductID]'
END
GO

-- Drop Foreign Key Constraint [FK_Product_ProductModel_ProductModelID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_Product_ProductModel_ProductModelID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[Product]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCT] 
               DROP CONSTRAINT [FK_Product_ProductModel_ProductModelID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Product_ProductModel_ProductModelID]'
END
GO

-- Drop Foreign Key Constraint [FK_Product_ProductSubcategory_ProductSubcategoryID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_Product_ProductSubcategory_ProductSubcategoryID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[Product]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCT] 
               DROP CONSTRAINT [FK_Product_ProductSubcategory_ProductSubcategoryID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Product_ProductSubcategory_ProductSubcategoryID]'
END
GO

-- Drop Foreign Key Constraint [FK_Product_UnitMeasure_SizeUnitMeasureCode]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_Product_UnitMeasure_SizeUnitMeasureCode]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[Product]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCT] 
               DROP CONSTRAINT [FK_Product_UnitMeasure_SizeUnitMeasureCode]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Product_UnitMeasure_SizeUnitMeasureCode]'
END
GO

-- Drop Foreign Key Constraint [FK_Product_UnitMeasure_WeightUnitMeasureCode]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_Product_UnitMeasure_WeightUnitMeasureCode]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[Product]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCT] 
               DROP CONSTRAINT [FK_Product_UnitMeasure_WeightUnitMeasureCode]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Product_UnitMeasure_WeightUnitMeasureCode]'
END
GO

-- Delete From [Production].[Product]
BEGIN
    DELETE FROM [Production].[Product]
    Print 'Deleted From [Production].[Product]'
    DBCC CHECKIDENT ('[Production].[Product]',RESEED,1)
    Print 'Reset Identity Seed To 1 for [Production].[Product]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductModelIllustration_Illustration_IllustrationID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductModelIllustration_Illustration_IllustrationID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductModelIllustration]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTMODELILLUSTRATION] 
               DROP CONSTRAINT [FK_ProductModelIllustration_Illustration_IllustrationID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductModelIllustration_Illustration_IllustrationID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductModelIllustration_ProductModel_ProductModelID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductModelIllustration_ProductModel_ProductModelID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductModelIllustration]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTMODELILLUSTRATION] 
               DROP CONSTRAINT [FK_ProductModelIllustration_ProductModel_ProductModelID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductModelIllustration_ProductModel_ProductModelID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductModelProductDescriptionCulture_Culture_CultureID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductModelProductDescriptionCulture_Culture_CultureID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductModelProductDescriptionCulture]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTMODELPRODUCTDESCRIPTIONCULTURE] 
               DROP CONSTRAINT [FK_ProductModelProductDescriptionCulture_Culture_CultureID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductModelProductDescriptionCulture_Culture_CultureID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductModelProductDescriptionCulture]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTMODELPRODUCTDESCRIPTIONCULTURE] 
               DROP CONSTRAINT [FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductModelProductDescriptionCulture]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTMODELPRODUCTDESCRIPTIONCULTURE] 
               DROP CONSTRAINT [FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID]'
END
GO

-- Delete From [Production].[ProductModelProductDescriptionCulture]
BEGIN
    DELETE FROM [Production].[ProductModelProductDescriptionCulture]
    Print 'Deleted From [Production].[ProductModelProductDescriptionCulture]'
END
GO

-- Drop Foreign Key Constraint [FK_ProductSubcategory_ProductCategory_ProductCategoryID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Production].[FK_ProductSubcategory_ProductCategory_ProductCategoryID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Production].[ProductSubcategory]')) BEGIN 
    ALTER TABLE [PRODUCTION].[PRODUCTSUBCATEGORY] 
               DROP CONSTRAINT [FK_ProductSubcategory_ProductCategory_ProductCategoryID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ProductSubcategory_ProductCategory_ProductCategoryID]'
END
GO

-- Drop Foreign Key Constraint [FK_VendorContact_Contact_ContactID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_VendorContact_Contact_ContactID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[VendorContact]')) BEGIN 
    ALTER TABLE [PURCHASING].[VENDORCONTACT] 
               DROP CONSTRAINT [FK_VendorContact_Contact_ContactID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_VendorContact_Contact_ContactID]'
END
GO

-- Drop Foreign Key Constraint [FK_VendorContact_ContactType_ContactTypeID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_VendorContact_ContactType_ContactTypeID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[VendorContact]')) BEGIN 
    ALTER TABLE [PURCHASING].[VENDORCONTACT] 
               DROP CONSTRAINT [FK_VendorContact_ContactType_ContactTypeID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_VendorContact_ContactType_ContactTypeID]'
END
GO

-- Drop Foreign Key Constraint [FK_VendorContact_Vendor_VendorID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Purchasing].[FK_VendorContact_Vendor_VendorID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Purchasing].[VendorContact]')) BEGIN 
    ALTER TABLE [PURCHASING].[VENDORCONTACT] 
               DROP CONSTRAINT [FK_VendorContact_Vendor_VendorID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_VendorContact_Vendor_VendorID]'
END
GO

-- Drop Foreign Key Constraint [FK_ContactCreditCard_Contact_ContactID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_ContactCreditCard_Contact_ContactID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[ContactCreditCard]')) BEGIN 
    ALTER TABLE [SALES].[CONTACTCREDITCARD] 
               DROP CONSTRAINT [FK_ContactCreditCard_Contact_ContactID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ContactCreditCard_Contact_ContactID]'
END
GO

-- Drop Foreign Key Constraint [FK_ContactCreditCard_CreditCard_CreditCardID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_ContactCreditCard_CreditCard_CreditCardID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[ContactCreditCard]')) BEGIN 
    ALTER TABLE [SALES].[CONTACTCREDITCARD] 
               DROP CONSTRAINT [FK_ContactCreditCard_CreditCard_CreditCardID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_ContactCreditCard_CreditCard_CreditCardID]'
END
GO

-- Drop Foreign Key Constraint [FK_CountryRegionCurrency_CountryRegion_CountryRegionCode]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_CountryRegionCurrency_CountryRegion_CountryRegionCode]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[CountryRegionCurrency]')) BEGIN 
    ALTER TABLE [SALES].[COUNTRYREGIONCURRENCY] 
               DROP CONSTRAINT [FK_CountryRegionCurrency_CountryRegion_CountryRegionCode]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_CountryRegionCurrency_CountryRegion_CountryRegionCode]'
END
GO

-- Drop Foreign Key Constraint [FK_CountryRegionCurrency_Currency_CurrencyCode]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_CountryRegionCurrency_Currency_CurrencyCode]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[CountryRegionCurrency]')) BEGIN 
    ALTER TABLE [SALES].[COUNTRYREGIONCURRENCY] 
               DROP CONSTRAINT [FK_CountryRegionCurrency_Currency_CurrencyCode]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_CountryRegionCurrency_Currency_CurrencyCode]'
END
GO

-- Drop Foreign Key Constraint [FK_CurrencyRate_Currency_FromCurrencyCode]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_CurrencyRate_Currency_FromCurrencyCode]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[CurrencyRate]')) BEGIN 
    ALTER TABLE [SALES].[CURRENCYRATE] 
               DROP CONSTRAINT [FK_CurrencyRate_Currency_FromCurrencyCode]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_CurrencyRate_Currency_FromCurrencyCode]'
END
GO

-- Drop Foreign Key Constraint [FK_CurrencyRate_Currency_ToCurrencyCode]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_CurrencyRate_Currency_ToCurrencyCode]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[CurrencyRate]')) BEGIN 
    ALTER TABLE [SALES].[CURRENCYRATE] 
               DROP CONSTRAINT [FK_CurrencyRate_Currency_ToCurrencyCode]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_CurrencyRate_Currency_ToCurrencyCode]'
END
GO

-- Drop Foreign Key Constraint [FK_Individual_Customer_CustomerID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_Individual_Customer_CustomerID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[Individual]')) BEGIN 
    ALTER TABLE [SALES].[INDIVIDUAL] 
               DROP CONSTRAINT [FK_Individual_Customer_CustomerID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Individual_Customer_CustomerID]'
END
GO

-- Drop Foreign Key Constraint [FK_Individual_Contact_ContactID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_Individual_Contact_ContactID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[Individual]')) BEGIN 
    ALTER TABLE [SALES].[INDIVIDUAL] 
               DROP CONSTRAINT [FK_Individual_Contact_ContactID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Individual_Contact_ContactID]'
END
GO

-- Drop Foreign Key Constraint [FK_Customer_SalesTerritory_TerritoryID]
IF EXISTS (SELECT * FROM sys.foreign_keys 
           WHERE object_id =
                 OBJECT_ID(N'[Sales].[FK_Customer_SalesTerritory_TerritoryID]') 
                 AND parent_object_id =
                 OBJECT_ID('[Sales].[Customer]')) BEGIN 
    ALTER TABLE [SALES].[CUSTOMER] 
               DROP CONSTRAINT [FK_Customer_SalesTerritory_TerritoryID]
    Print 'Dropped Foreign Key Constraint ' + 
		  '[FK_Customer_SalesTerritory_TerritoryID]'
END
GO

-- Delete From [Person].[CountryRegion]
BEGIN
    DELETE FROM [Person].[CountryRegion]
    Print 'Deleted From [Person].[CountryRegion]'
END
GO

-- Delete From [Production].[ProductDescription]
BEGIN
    DELETE FROM [Production].[ProductDescription]
    Print 'Deleted From [Production].[ProductDescription]'
    DBCC CHECKIDENT ('[Production].[ProductDescription]',RESEED,1)
    Print 'Reset Identity Seed To 1 for [Production].[ProductDescription]'
END
GO

-- Delete From [Production].[ProductModel]
BEGIN
    DELETE FROM [Production].[ProductModel]
    Print 'Deleted From [Production].[ProductModel]'
    DBCC CHECKIDENT ('[Production].[ProductModel]',RESEED,1)
    Print 'Reset Identity Seed To 1 for [Production].[ProductModel]'
END
GO

-- Create Foreign Key Constraint [FK_StoreContact_Store_CustomerID]
BEGIN
    ALTER TABLE [SALES].[STORECONTACT] WITH CHECK 
                 ADD CONSTRAINT [FK_StoreContact_Store_CustomerID] 
				 FOREIGN KEY([CustomerID]) 
				 REFERENCES [Sales].[Store] ([CustomerID]) 
    ALTER TABLE [SALES].[STORECONTACT] 
				CHECK CONSTRAINT [FK_StoreContact_Store_CustomerID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		
		@value='Foreign key constraint referencing Store.CustomerID.', 
		@level0type='schema',@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='StoreContact', 
		@level2type='CONSTRAINT',
		@level2name='FK_StoreContact_Store_CustomerID'
    Print 'Added Extended Property MS_Description to FK_StoreContact_Store_CustomerID'
    Print 'Created Foreign Key Constraint [FK_StoreContact_Store_CustomerID]'
END
GO

-- Create Foreign Key Constraint [FK_StoreContact_Contact_ContactID]
BEGIN
    ALTER TABLE [SALES].[STORECONTACT] WITH CHECK 
                 ADD CONSTRAINT [FK_StoreContact_Contact_ContactID] 
				 FOREIGN KEY([ContactID])
				 REFERENCES [Person].[Contact] ([ContactID]) 
    ALTER TABLE [SALES].[STORECONTACT] 
				CHECK CONSTRAINT [FK_StoreContact_Contact_ContactID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Contact.ContactID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='StoreContact', 
		@level2type='CONSTRAINT',
		@level2name='FK_StoreContact_Contact_ContactID'
    Print 'Added Extended Property MS_Description to FK_StoreContact_Contact_ContactID'
    Print 'Created Foreign Key Constraint [FK_StoreContact_Contact_ContactID]'
END
GO

-- Create Foreign Key Constraint [FK_StoreContact_ContactType_ContactTypeID]
BEGIN
    ALTER TABLE [SALES].[STORECONTACT] WITH CHECK 
                 ADD CONSTRAINT [FK_StoreContact_ContactType_ContactTypeID] 
				 FOREIGN KEY([ContactTypeID])
				 REFERENCES [Person].[ContactType] ([ContactTypeID]) 
    ALTER TABLE [SALES].[STORECONTACT] 
				CHECK CONSTRAINT [FK_StoreContact_ContactType_ContactTypeID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ContactType.ContactTypeID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='StoreContact', 
		@level2type='CONSTRAINT',
		@level2name='FK_StoreContact_ContactType_ContactTypeID'
    Print 'Added Extended Property MS_Description to FK_StoreContact_ContactType_ContactTypeID'
    Print 'Created Foreign Key Constraint [FK_StoreContact_ContactType_ContactTypeID]'
END
GO

-- Create Foreign Key Constraint [FK_Store_SalesPerson_SalesPersonID]
BEGIN
    ALTER TABLE [SALES].[STORE] WITH CHECK 
                 ADD CONSTRAINT [FK_Store_SalesPerson_SalesPersonID] 
				 FOREIGN KEY([SalesPersonID])
				 REFERENCES [Sales].[SalesPerson] ([SalesPersonID]) 
    ALTER TABLE [SALES].[STORE] 
				CHECK CONSTRAINT [FK_Store_SalesPerson_SalesPersonID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesPerson.SalesPersonID', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='Store', 
		@level2type='CONSTRAINT',
		@level2name='FK_Store_SalesPerson_SalesPersonID'
    Print 'Added Extended Property MS_Description to FK_Store_SalesPerson_SalesPersonID'
    Print 'Created Foreign Key Constraint [FK_Store_SalesPerson_SalesPersonID]'
END
GO

-- Create Foreign Key Constraint [FK_Store_Customer_CustomerID]
BEGIN
    ALTER TABLE [SALES].[STORE] WITH CHECK 
                 ADD CONSTRAINT [FK_Store_Customer_CustomerID] 
				 FOREIGN KEY([CustomerID])
				 REFERENCES [Sales].[Customer] ([CustomerID]) 
    ALTER TABLE [SALES].[STORE] 
				CHECK CONSTRAINT [FK_Store_Customer_CustomerID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Customer.CustomerID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='Store', 
		@level2type='CONSTRAINT',
		@level2name='FK_Store_Customer_CustomerID'
    Print 'Added Extended Property MS_Description to FK_Store_Customer_CustomerID'
    Print 'Created Foreign Key Constraint [FK_Store_Customer_CustomerID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesTerritoryHistory_SalesPerson_SalesPersonID]
BEGIN
    ALTER TABLE [SALES].[SALESTERRITORYHISTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesTerritoryHistory_SalesPerson_SalesPersonID] 
				 FOREIGN KEY([SalesPersonID])
				 REFERENCES [Sales].[SalesPerson] ([SalesPersonID]) 
    ALTER TABLE [SALES].[SALESTERRITORYHISTORY] 
				CHECK CONSTRAINT [FK_SalesTerritoryHistory_SalesPerson_SalesPersonID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesPerson.SalesPersonID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesTerritoryHistory', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesTerritoryHistory_SalesPerson_SalesPersonID'
    Print 'Added Extended Property MS_Description to FK_SalesTerritoryHistory_SalesPerson_SalesPersonID'
    Print 'Created Foreign Key Constraint [FK_SalesTerritoryHistory_SalesPerson_SalesPersonID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesTerritoryHistory_SalesTerritory_TerritoryID]
BEGIN
    ALTER TABLE [SALES].[SALESTERRITORYHISTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesTerritoryHistory_SalesTerritory_TerritoryID] 
				 FOREIGN KEY([TerritoryID])
				 REFERENCES [Sales].[SalesTerritory] ([TerritoryID]) 
    ALTER TABLE [SALES].[SALESTERRITORYHISTORY] 
				CHECK CONSTRAINT [FK_SalesTerritoryHistory_SalesTerritory_TerritoryID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesTerritory.TerritoryID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesTerritoryHistory', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesTerritoryHistory_SalesTerritory_TerritoryID'
    Print 'Added Extended Property MS_Description to FK_SalesTerritoryHistory_SalesTerritory_TerritoryID'
    Print 'Created Foreign Key Constraint [FK_SalesTerritoryHistory_SalesTerritory_TerritoryID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonID]
BEGIN
    ALTER TABLE [SALES].[SALESPERSONQUOTAHISTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonID] 
				 FOREIGN KEY([SalesPersonID])
				 REFERENCES [Sales].[SalesPerson] ([SalesPersonID]) 
    ALTER TABLE [SALES].[SALESPERSONQUOTAHISTORY] 
				CHECK CONSTRAINT [FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesPerson.SalesPersonID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesPersonQuotaHistory', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonID'
    Print 'Added Extended Property MS_Description to FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonID'
    Print 'Created Foreign Key Constraint [FK_SalesPersonQuotaHistory_SalesPerson_SalesPersonID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERHEADERSALESREASON] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID] 
				 FOREIGN KEY([SalesOrderID])
				 REFERENCES [Sales].[SalesOrderHeader] ([SalesOrderID]) ON DELETE CASCADE 
    ALTER TABLE [SALES].[SALESORDERHEADERSALESREASON] 
				CHECK CONSTRAINT [FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesOrderHeader.SalesOrderID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderHeaderSalesReason', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderHeaderSalesReason_SalesOrderHeader_SalesOrderID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERHEADERSALESREASON] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID] 
				 FOREIGN KEY([SalesReasonID])
				 REFERENCES [Sales].[SalesReason] ([SalesReasonID]) 
    ALTER TABLE [SALES].[SALESORDERHEADERSALESREASON] 
				CHECK CONSTRAINT [FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesReason.SalesReasonID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderHeaderSalesReason', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderHeaderSalesReason_SalesReason_SalesReasonID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERDETAIL] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID] 
				 FOREIGN KEY([SalesOrderID])
				 REFERENCES [Sales].[SalesOrderHeader] ([SalesOrderID]) ON DELETE CASCADE 
    ALTER TABLE [SALES].[SALESORDERDETAIL] 
				CHECK CONSTRAINT [FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesOrderHeader.PurchaseOrderID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderDetail', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERDETAIL] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID] 
				 FOREIGN KEY([SpecialOfferID], [ProductID])
				 REFERENCES [Sales].[SpecialOfferProduct] ([SpecialOfferID], [ProductID]) 
    ALTER TABLE [SALES].[SALESORDERDETAIL] 
				CHECK CONSTRAINT [FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SpecialOfferProduct.SpecialOfferIDProductID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderDetail', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderDetail_SpecialOfferProduct_SpecialOfferIDProductID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderHeader_SalesPerson_SalesPersonID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderHeader_SalesPerson_SalesPersonID] 
				 FOREIGN KEY([SalesPersonID])
				 REFERENCES [Sales].[SalesPerson] ([SalesPersonID]) 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
				CHECK CONSTRAINT [FK_SalesOrderHeader_SalesPerson_SalesPersonID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesPerson.SalesPersonID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderHeader_SalesPerson_SalesPersonID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderHeader_SalesPerson_SalesPersonID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderHeader_SalesPerson_SalesPersonID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderHeader_Address_ShipToAddressID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderHeader_Address_ShipToAddressID] 
				 FOREIGN KEY([ShipToAddressID])
				 REFERENCES [Person].[Address] ([AddressID]) 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
				CHECK CONSTRAINT [FK_SalesOrderHeader_Address_ShipToAddressID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Address.AddressID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderHeader_Address_ShipToAddressID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderHeader_Address_ShipToAddressID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderHeader_Address_ShipToAddressID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderHeader_Address_BillToAddressID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderHeader_Address_BillToAddressID] 
				 FOREIGN KEY([BillToAddressID])
				 REFERENCES [Person].[Address] ([AddressID]) 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
				CHECK CONSTRAINT [FK_SalesOrderHeader_Address_BillToAddressID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Address.AddressID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderHeader_Address_BillToAddressID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderHeader_Address_BillToAddressID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderHeader_Address_BillToAddressID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderHeader_CurrencyRate_CurrencyRateID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderHeader_CurrencyRate_CurrencyRateID] 
				 FOREIGN KEY([CurrencyRateID])
				 REFERENCES [Sales].[CurrencyRate] ([CurrencyRateID]) 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
				CHECK CONSTRAINT [FK_SalesOrderHeader_CurrencyRate_CurrencyRateID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing CurrencyRate.CurrencyRateID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderHeader_CurrencyRate_CurrencyRateID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderHeader_CurrencyRate_CurrencyRateID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderHeader_CurrencyRate_CurrencyRateID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderHeader_Customer_CustomerID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderHeader_Customer_CustomerID] 
				 FOREIGN KEY([CustomerID])
				 REFERENCES [Sales].[Customer] ([CustomerID]) 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
				CHECK CONSTRAINT [FK_SalesOrderHeader_Customer_CustomerID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Customer.CustomerID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderHeader_Customer_CustomerID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderHeader_Customer_CustomerID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderHeader_Customer_CustomerID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderHeader_Contact_ContactID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderHeader_Contact_ContactID] 
				 FOREIGN KEY([ContactID])
				 REFERENCES [Person].[Contact] ([ContactID]) 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
				CHECK CONSTRAINT [FK_SalesOrderHeader_Contact_ContactID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Contact.ContactID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderHeader_Contact_ContactID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderHeader_Contact_ContactID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderHeader_Contact_ContactID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderHeader_CreditCard_CreditCardID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderHeader_CreditCard_CreditCardID] 
				 FOREIGN KEY([CreditCardID])
				 REFERENCES [Sales].[CreditCard] ([CreditCardID]) 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
				CHECK CONSTRAINT [FK_SalesOrderHeader_CreditCard_CreditCardID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing CreditCard.CreditCardID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderHeader_CreditCard_CreditCardID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderHeader_CreditCard_CreditCardID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderHeader_CreditCard_CreditCardID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderHeader_SalesTerritory_TerritoryID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderHeader_SalesTerritory_TerritoryID] 
				 FOREIGN KEY([TerritoryID])
				 REFERENCES [Sales].[SalesTerritory] ([TerritoryID]) 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
				CHECK CONSTRAINT [FK_SalesOrderHeader_SalesTerritory_TerritoryID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesTerritory.TerritoryID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderHeader_SalesTerritory_TerritoryID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderHeader_SalesTerritory_TerritoryID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderHeader_SalesTerritory_TerritoryID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesOrderHeader_ShipMethod_ShipMethodID]
BEGIN
    ALTER TABLE [SALES].[SALESORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesOrderHeader_ShipMethod_ShipMethodID] 
				 FOREIGN KEY([ShipMethodID])
				 REFERENCES [Purchasing].[ShipMethod] ([ShipMethodID]) 
    ALTER TABLE [SALES].[SALESORDERHEADER] 
				CHECK CONSTRAINT [FK_SalesOrderHeader_ShipMethod_ShipMethodID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ShipMethod.ShipMethodID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesOrderHeader_ShipMethod_ShipMethodID'
    Print 'Added Extended Property MS_Description to FK_SalesOrderHeader_ShipMethod_ShipMethodID'
    Print 'Created Foreign Key Constraint [FK_SalesOrderHeader_ShipMethod_ShipMethodID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesPerson_Employee_SalesPersonID]
BEGIN
    ALTER TABLE [SALES].[SALESPERSON] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesPerson_Employee_SalesPersonID] 
				 FOREIGN KEY([SalesPersonID])
				 REFERENCES [HumanResources].[Employee] ([EmployeeID]) 
    ALTER TABLE [SALES].[SALESPERSON] 
				CHECK CONSTRAINT [FK_SalesPerson_Employee_SalesPersonID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Employee.EmployeeID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesPerson', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesPerson_Employee_SalesPersonID'
    Print 'Added Extended Property MS_Description to FK_SalesPerson_Employee_SalesPersonID'
    Print 'Created Foreign Key Constraint [FK_SalesPerson_Employee_SalesPersonID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesPerson_SalesTerritory_TerritoryID]
BEGIN
    ALTER TABLE [SALES].[SALESPERSON] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesPerson_SalesTerritory_TerritoryID] 
				 FOREIGN KEY([TerritoryID])
				 REFERENCES [Sales].[SalesTerritory] ([TerritoryID]) 
    ALTER TABLE [SALES].[SALESPERSON] 
				CHECK CONSTRAINT [FK_SalesPerson_SalesTerritory_TerritoryID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesTerritory.TerritoryID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesPerson', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesPerson_SalesTerritory_TerritoryID'
    Print 'Added Extended Property MS_Description to FK_SalesPerson_SalesTerritory_TerritoryID'
    Print 'Created Foreign Key Constraint [FK_SalesPerson_SalesTerritory_TerritoryID]'
END
GO

-- Create Foreign Key Constraint [FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID]
BEGIN
    ALTER TABLE [PURCHASING].[PURCHASEORDERDETAIL] WITH CHECK 
                 ADD CONSTRAINT [FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID] 
				 FOREIGN KEY([PurchaseOrderID])
				 REFERENCES [Purchasing].[PurchaseOrderHeader] ([PurchaseOrderID]) 
    ALTER TABLE [PURCHASING].[PURCHASEORDERDETAIL] 
				CHECK CONSTRAINT [FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing PurchaseOrderHeader.PurchaseOrderID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='PurchaseOrderDetail', 
		@level2type='CONSTRAINT',
		@level2name='FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID'
    Print 'Added Extended Property MS_Description to FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID'
    Print 'Created Foreign Key Constraint [FK_PurchaseOrderDetail_PurchaseOrderHeader_PurchaseOrderID]'
END
GO

-- Create Foreign Key Constraint [FK_PurchaseOrderDetail_Product_ProductID]
BEGIN
    ALTER TABLE [PURCHASING].[PURCHASEORDERDETAIL] WITH CHECK 
                 ADD CONSTRAINT [FK_PurchaseOrderDetail_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PURCHASING].[PURCHASEORDERDETAIL] 
				CHECK CONSTRAINT [FK_PurchaseOrderDetail_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='PurchaseOrderDetail', 
		@level2type='CONSTRAINT',
		@level2name='FK_PurchaseOrderDetail_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_PurchaseOrderDetail_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_PurchaseOrderDetail_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_PurchaseOrderHeader_Employee_EmployeeID]
BEGIN
    ALTER TABLE [PURCHASING].[PURCHASEORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_PurchaseOrderHeader_Employee_EmployeeID] 
				 FOREIGN KEY([EmployeeID])
				 REFERENCES [HumanResources].[Employee] ([EmployeeID]) 
    ALTER TABLE [PURCHASING].[PURCHASEORDERHEADER] 
				CHECK CONSTRAINT [FK_PurchaseOrderHeader_Employee_EmployeeID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Employee.EmployeeID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='PurchaseOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_PurchaseOrderHeader_Employee_EmployeeID'
    Print 'Added Extended Property MS_Description to FK_PurchaseOrderHeader_Employee_EmployeeID'
    Print 'Created Foreign Key Constraint [FK_PurchaseOrderHeader_Employee_EmployeeID]'
END
GO

-- Create Foreign Key Constraint [FK_PurchaseOrderHeader_ShipMethod_ShipMethodID]
BEGIN
    ALTER TABLE [PURCHASING].[PURCHASEORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_PurchaseOrderHeader_ShipMethod_ShipMethodID] 
				 FOREIGN KEY([ShipMethodID])
				 REFERENCES [Purchasing].[ShipMethod] ([ShipMethodID]) 
    ALTER TABLE [PURCHASING].[PURCHASEORDERHEADER] 
				CHECK CONSTRAINT [FK_PurchaseOrderHeader_ShipMethod_ShipMethodID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ShipMethod.ShipMethodID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='PurchaseOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_PurchaseOrderHeader_ShipMethod_ShipMethodID'
    Print 'Added Extended Property MS_Description to FK_PurchaseOrderHeader_ShipMethod_ShipMethodID'
    Print 'Created Foreign Key Constraint [FK_PurchaseOrderHeader_ShipMethod_ShipMethodID]'
END
GO

-- Create Foreign Key Constraint [FK_PurchaseOrderHeader_Vendor_VendorID]
BEGIN
    ALTER TABLE [PURCHASING].[PURCHASEORDERHEADER] WITH CHECK 
                 ADD CONSTRAINT [FK_PurchaseOrderHeader_Vendor_VendorID] 
				 FOREIGN KEY([VendorID])
				 REFERENCES [Purchasing].[Vendor] ([VendorID]) 
    ALTER TABLE [PURCHASING].[PURCHASEORDERHEADER] 
				CHECK CONSTRAINT [FK_PurchaseOrderHeader_Vendor_VendorID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Vendor.VendorID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='PurchaseOrderHeader', 
		@level2type='CONSTRAINT',
		@level2name='FK_PurchaseOrderHeader_Vendor_VendorID'
    Print 'Added Extended Property MS_Description to FK_PurchaseOrderHeader_Vendor_VendorID'
    Print 'Created Foreign Key Constraint [FK_PurchaseOrderHeader_Vendor_VendorID]'
END
GO

-- Create Foreign Key Constraint [FK_JobCandidate_Employee_EmployeeID]
BEGIN
    ALTER TABLE [HUMANRESOURCES].[JOBCANDIDATE] WITH CHECK 
                 ADD CONSTRAINT [FK_JobCandidate_Employee_EmployeeID] 
				 FOREIGN KEY([EmployeeID])
				 REFERENCES [HumanResources].[Employee] ([EmployeeID]) 
    ALTER TABLE [HUMANRESOURCES].[JOBCANDIDATE] 
				CHECK CONSTRAINT [FK_JobCandidate_Employee_EmployeeID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Employee.EmployeeID.', 
		@level0type='schema',
		@level0name='HumanResources', 
		@level1type='TABLE', 
		@level1name='JobCandidate', 
		@level2type='CONSTRAINT',
		@level2name='FK_JobCandidate_Employee_EmployeeID'
    Print 'Added Extended Property MS_Description to FK_JobCandidate_Employee_EmployeeID'
    Print 'Created Foreign Key Constraint [FK_JobCandidate_Employee_EmployeeID]'
END
GO

-- Create Foreign Key Constraint [FK_EmployeePayHistory_Employee_EmployeeID]
BEGIN
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEPAYHISTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_EmployeePayHistory_Employee_EmployeeID] 
				 FOREIGN KEY([EmployeeID])
				 REFERENCES [HumanResources].[Employee] ([EmployeeID]) 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEPAYHISTORY] 
				CHECK CONSTRAINT [FK_EmployeePayHistory_Employee_EmployeeID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Employee.EmployeeID.', 
		@level0type='schema',
		@level0name='HumanResources', 
		@level1type='TABLE', 
		@level1name='EmployeePayHistory', 
		@level2type='CONSTRAINT',
		@level2name='FK_EmployeePayHistory_Employee_EmployeeID'
    Print 'Added Extended Property MS_Description to FK_EmployeePayHistory_Employee_EmployeeID'
    Print 'Created Foreign Key Constraint [FK_EmployeePayHistory_Employee_EmployeeID]'
END
GO

-- Create Foreign Key Constraint [FK_EmployeeDepartmentHistory_Employee_EmployeeID]
BEGIN
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEDEPARTMENTHISTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_EmployeeDepartmentHistory_Employee_EmployeeID] 
				 FOREIGN KEY([EmployeeID])
				 REFERENCES [HumanResources].[Employee] ([EmployeeID]) 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEDEPARTMENTHISTORY] 
				CHECK CONSTRAINT [FK_EmployeeDepartmentHistory_Employee_EmployeeID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Employee.EmployeeID.', 
		@level0type='schema',
		@level0name='HumanResources', 
		@level1type='TABLE', 
		@level1name='EmployeeDepartmentHistory', 
		@level2type='CONSTRAINT',
		@level2name='FK_EmployeeDepartmentHistory_Employee_EmployeeID'
    Print 'Added Extended Property MS_Description to FK_EmployeeDepartmentHistory_Employee_EmployeeID'
    Print 'Created Foreign Key Constraint [FK_EmployeeDepartmentHistory_Employee_EmployeeID]'
END
GO

-- Create Foreign Key Constraint [FK_EmployeeDepartmentHistory_Department_DepartmentID]
BEGIN
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEDEPARTMENTHISTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_EmployeeDepartmentHistory_Department_DepartmentID] 
				 FOREIGN KEY([DepartmentID])
				 REFERENCES [HumanResources].[Department] ([DepartmentID]) 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEDEPARTMENTHISTORY] 
				CHECK CONSTRAINT [FK_EmployeeDepartmentHistory_Department_DepartmentID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Department.DepartmentID.', 
		@level0type='schema',
		@level0name='HumanResources', 
		@level1type='TABLE', 
		@level1name='EmployeeDepartmentHistory', 
		@level2type='CONSTRAINT',
		@level2name='FK_EmployeeDepartmentHistory_Department_DepartmentID'
    Print 'Added Extended Property MS_Description to FK_EmployeeDepartmentHistory_Department_DepartmentID'
    Print 'Created Foreign Key Constraint [FK_EmployeeDepartmentHistory_Department_DepartmentID]'
END
GO

-- Create Foreign Key Constraint [FK_EmployeeDepartmentHistory_Shift_ShiftID]
BEGIN
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEDEPARTMENTHISTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_EmployeeDepartmentHistory_Shift_ShiftID] 
				 FOREIGN KEY([ShiftID])
				 REFERENCES [HumanResources].[Shift] ([ShiftID]) 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEDEPARTMENTHISTORY] 
				CHECK CONSTRAINT [FK_EmployeeDepartmentHistory_Shift_ShiftID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Shift.ShiftID', 
		@level0type='schema',
		@level0name='HumanResources', 
		@level1type='TABLE', 
		@level1name='EmployeeDepartmentHistory', 
		@level2type='CONSTRAINT',
		@level2name='FK_EmployeeDepartmentHistory_Shift_ShiftID'
    Print 'Added Extended Property MS_Description to FK_EmployeeDepartmentHistory_Shift_ShiftID'
    Print 'Created Foreign Key Constraint [FK_EmployeeDepartmentHistory_Shift_ShiftID]'
END
GO

-- Create Foreign Key Constraint [FK_EmployeeAddress_Employee_EmployeeID]
BEGIN
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEADDRESS] WITH CHECK 
                 ADD CONSTRAINT [FK_EmployeeAddress_Employee_EmployeeID] 
				 FOREIGN KEY([EmployeeID])
				 REFERENCES [HumanResources].[Employee] ([EmployeeID]) 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEADDRESS] 
				CHECK CONSTRAINT [FK_EmployeeAddress_Employee_EmployeeID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Employee.EmployeeID.', 
		@level0type='schema',
		@level0name='HumanResources', 
		@level1type='TABLE', 
		@level1name='EmployeeAddress', 
		@level2type='CONSTRAINT',
		@level2name='FK_EmployeeAddress_Employee_EmployeeID'
    Print 'Added Extended Property MS_Description to FK_EmployeeAddress_Employee_EmployeeID'
    Print 'Created Foreign Key Constraint [FK_EmployeeAddress_Employee_EmployeeID]'
END
GO

-- Create Foreign Key Constraint [FK_EmployeeAddress_Address_AddressID]
BEGIN
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEADDRESS] WITH CHECK 
                 ADD CONSTRAINT [FK_EmployeeAddress_Address_AddressID] 
				 FOREIGN KEY([AddressID])
				 REFERENCES [Person].[Address] ([AddressID]) 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEEADDRESS] 
				CHECK CONSTRAINT [FK_EmployeeAddress_Address_AddressID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Address.AddressID.', 
		@level0type='schema',
		@level0name='HumanResources', 
		@level1type='TABLE', 
		@level1name='EmployeeAddress', 
		@level2type='CONSTRAINT',
		@level2name='FK_EmployeeAddress_Address_AddressID'
    Print 'Added Extended Property MS_Description to FK_EmployeeAddress_Address_AddressID'
    Print 'Created Foreign Key Constraint [FK_EmployeeAddress_Address_AddressID]'
END
GO

-- Create Foreign Key Constraint [FK_Employee_Employee_ManagerID]
BEGIN
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEE] WITH CHECK 
                 ADD CONSTRAINT [FK_Employee_Employee_ManagerID] 
				 FOREIGN KEY([ManagerID])
				 REFERENCES [HumanResources].[Employee] ([EmployeeID]) 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEE] 
				CHECK CONSTRAINT [FK_Employee_Employee_ManagerID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Employee.ManagerID.', 
		@level0type='schema',
		@level0name='HumanResources', 
		@level1type='TABLE', 
		@level1name='Employee', 
		@level2type='CONSTRAINT',
		@level2name='FK_Employee_Employee_ManagerID'
    Print 'Added Extended Property MS_Description to FK_Employee_Employee_ManagerID'
    Print 'Created Foreign Key Constraint [FK_Employee_Employee_ManagerID]'
END
GO

-- Create Foreign Key Constraint [FK_Employee_Contact_ContactID]
BEGIN
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEE] WITH CHECK 
                 ADD CONSTRAINT [FK_Employee_Contact_ContactID] 
				 FOREIGN KEY([ContactID])
				 REFERENCES [Person].[Contact] ([ContactID]) 
    ALTER TABLE [HUMANRESOURCES].[EMPLOYEE] 
				CHECK CONSTRAINT [FK_Employee_Contact_ContactID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Contact.ContactID.', 
		@level0type='schema',
		@level0name='HumanResources', 
		@level1type='TABLE', 
		@level1name='Employee', 
		@level2type='CONSTRAINT',
		@level2name='FK_Employee_Contact_ContactID'
    Print 'Added Extended Property MS_Description to FK_Employee_Contact_ContactID'
    Print 'Created Foreign Key Constraint [FK_Employee_Contact_ContactID]'
END
GO

-- Create Foreign Key Constraint [FK_CustomerAddress_Address_AddressID]
BEGIN
    ALTER TABLE [SALES].[CUSTOMERADDRESS] WITH CHECK 
                 ADD CONSTRAINT [FK_CustomerAddress_Address_AddressID] 
				 FOREIGN KEY([AddressID])
				 REFERENCES [Person].[Address] ([AddressID]) 
    ALTER TABLE [SALES].[CUSTOMERADDRESS] 
				CHECK CONSTRAINT [FK_CustomerAddress_Address_AddressID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Address.AddressID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='CustomerAddress', 
		@level2type='CONSTRAINT',
		@level2name='FK_CustomerAddress_Address_AddressID'
    Print 'Added Extended Property MS_Description to FK_CustomerAddress_Address_AddressID'
    Print 'Created Foreign Key Constraint [FK_CustomerAddress_Address_AddressID]'
END
GO

-- Create Foreign Key Constraint [FK_CustomerAddress_Customer_CustomerID]
BEGIN
    ALTER TABLE [SALES].[CUSTOMERADDRESS] WITH CHECK 
                 ADD CONSTRAINT [FK_CustomerAddress_Customer_CustomerID] 
				 FOREIGN KEY([CustomerID])
				 REFERENCES [Sales].[Customer] ([CustomerID]) 
    ALTER TABLE [SALES].[CUSTOMERADDRESS] 
				CHECK CONSTRAINT [FK_CustomerAddress_Customer_CustomerID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Customer.CustomerID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='CustomerAddress', 
		@level2type='CONSTRAINT',
		@level2name='FK_CustomerAddress_Customer_CustomerID'
    Print 'Added Extended Property MS_Description to FK_CustomerAddress_Customer_CustomerID'
    Print 'Created Foreign Key Constraint [FK_CustomerAddress_Customer_CustomerID]'
END
GO

-- Create Foreign Key Constraint [FK_CustomerAddress_AddressType_AddressTypeID]
BEGIN
    ALTER TABLE [SALES].[CUSTOMERADDRESS] WITH CHECK 
                 ADD CONSTRAINT [FK_CustomerAddress_AddressType_AddressTypeID] 
				 FOREIGN KEY([AddressTypeID])
				 REFERENCES [Person].[AddressType] ([AddressTypeID]) 
    ALTER TABLE [SALES].[CUSTOMERADDRESS] 
				CHECK CONSTRAINT [FK_CustomerAddress_AddressType_AddressTypeID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing AddressType.AddressTypeID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='CustomerAddress', 
		@level2type='CONSTRAINT',
		@level2name='FK_CustomerAddress_AddressType_AddressTypeID'
    Print 'Added Extended Property MS_Description to FK_CustomerAddress_AddressType_AddressTypeID'
    Print 'Created Foreign Key Constraint [FK_CustomerAddress_AddressType_AddressTypeID]'
END
GO

-- Create Foreign Key Constraint [FK_VendorAddress_Address_AddressID]
BEGIN
    ALTER TABLE [PURCHASING].[VENDORADDRESS] WITH CHECK 
                 ADD CONSTRAINT [FK_VendorAddress_Address_AddressID] 
				 FOREIGN KEY([AddressID])
				 REFERENCES [Person].[Address] ([AddressID]) 
    ALTER TABLE [PURCHASING].[VENDORADDRESS] 
				CHECK CONSTRAINT [FK_VendorAddress_Address_AddressID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Address.AddressID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='VendorAddress', 
		@level2type='CONSTRAINT',
		@level2name='FK_VendorAddress_Address_AddressID'
    Print 'Added Extended Property MS_Description to FK_VendorAddress_Address_AddressID'
    Print 'Created Foreign Key Constraint [FK_VendorAddress_Address_AddressID]'
END
GO

-- Create Foreign Key Constraint [FK_VendorAddress_AddressType_AddressTypeID]
BEGIN
    ALTER TABLE [PURCHASING].[VENDORADDRESS] WITH CHECK 
                 ADD CONSTRAINT [FK_VendorAddress_AddressType_AddressTypeID] 
				 FOREIGN KEY([AddressTypeID])
				 REFERENCES [Person].[AddressType] ([AddressTypeID]) 
    ALTER TABLE [PURCHASING].[VENDORADDRESS] 
				CHECK CONSTRAINT [FK_VendorAddress_AddressType_AddressTypeID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing AddressType.AddressTypeID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='VendorAddress', 
		@level2type='CONSTRAINT',
		@level2name='FK_VendorAddress_AddressType_AddressTypeID'
    Print 'Added Extended Property MS_Description to FK_VendorAddress_AddressType_AddressTypeID'
    Print 'Created Foreign Key Constraint [FK_VendorAddress_AddressType_AddressTypeID]'
END
GO

-- Create Foreign Key Constraint [FK_VendorAddress_Vendor_VendorID]
BEGIN
    ALTER TABLE [PURCHASING].[VENDORADDRESS] WITH CHECK 
                 ADD CONSTRAINT [FK_VendorAddress_Vendor_VendorID] 
				 FOREIGN KEY([VendorID])
				 REFERENCES [Purchasing].[Vendor] ([VendorID]) 
    ALTER TABLE [PURCHASING].[VENDORADDRESS] 
				CHECK CONSTRAINT [FK_VendorAddress_Vendor_VendorID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Vendor.VendorID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='VendorAddress', 
		@level2type='CONSTRAINT',
		@level2name='FK_VendorAddress_Vendor_VendorID'
    Print 'Added Extended Property MS_Description to FK_VendorAddress_Vendor_VendorID'
    Print 'Created Foreign Key Constraint [FK_VendorAddress_Vendor_VendorID]'
END
GO

-- Create Foreign Key Constraint [FK_Address_StateProvince_StateProvinceID]
BEGIN
    ALTER TABLE [PERSON].[ADDRESS] WITH CHECK 
                 ADD CONSTRAINT [FK_Address_StateProvince_StateProvinceID] 
				 FOREIGN KEY([StateProvinceID])
				 REFERENCES [Person].[StateProvince] ([StateProvinceID]) 
    ALTER TABLE [PERSON].[ADDRESS] 
				CHECK CONSTRAINT [FK_Address_StateProvince_StateProvinceID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing StateProvince.StateProvinceID.', 
		@level0type='schema',
		@level0name='Person', 
		@level1type='TABLE', 
		@level1name='Address', 
		@level2type='CONSTRAINT',
		@level2name='FK_Address_StateProvince_StateProvinceID'
    Print 'Added Extended Property MS_Description to FK_Address_StateProvince_StateProvinceID'
    Print 'Created Foreign Key Constraint [FK_Address_StateProvince_StateProvinceID]'
END
GO

-- Create Foreign Key Constraint [FK_SalesTaxRate_StateProvince_StateProvinceID]
BEGIN
    ALTER TABLE [SALES].[SALESTAXRATE] WITH CHECK 
                 ADD CONSTRAINT [FK_SalesTaxRate_StateProvince_StateProvinceID] 
				 FOREIGN KEY([StateProvinceID])
				 REFERENCES [Person].[StateProvince] ([StateProvinceID]) 
    ALTER TABLE [SALES].[SALESTAXRATE] 
				CHECK CONSTRAINT [FK_SalesTaxRate_StateProvince_StateProvinceID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing StateProvince.StateProvinceID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SalesTaxRate', 
		@level2type='CONSTRAINT',
		@level2name='FK_SalesTaxRate_StateProvince_StateProvinceID'
    Print 'Added Extended Property MS_Description to FK_SalesTaxRate_StateProvince_StateProvinceID'
    Print 'Created Foreign Key Constraint [FK_SalesTaxRate_StateProvince_StateProvinceID]'
END
GO

-- Create Foreign Key Constraint [FK_StateProvince_CountryRegion_CountryRegionCode]
BEGIN
    ALTER TABLE [PERSON].[STATEPROVINCE] WITH CHECK 
                 ADD CONSTRAINT [FK_StateProvince_CountryRegion_CountryRegionCode] 
				 FOREIGN KEY([CountryRegionCode])
				 REFERENCES [Person].[CountryRegion] ([CountryRegionCode]) 
    ALTER TABLE [PERSON].[STATEPROVINCE] 
				CHECK CONSTRAINT [FK_StateProvince_CountryRegion_CountryRegionCode]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing CountryRegion.CountryRegionCode.', 
		@level0type='schema',
		@level0name='Person', 
		@level1type='TABLE', 
		@level1name='StateProvince', 
		@level2type='CONSTRAINT',
		@level2name='FK_StateProvince_CountryRegion_CountryRegionCode'
    Print 'Added Extended Property MS_Description to FK_StateProvince_CountryRegion_CountryRegionCode'
    Print 'Created Foreign Key Constraint [FK_StateProvince_CountryRegion_CountryRegionCode]'
END
GO

-- Create Foreign Key Constraint [FK_StateProvince_SalesTerritory_TerritoryID]
BEGIN
    ALTER TABLE [PERSON].[STATEPROVINCE] WITH CHECK 
                 ADD CONSTRAINT [FK_StateProvince_SalesTerritory_TerritoryID] 
				 FOREIGN KEY([TerritoryID])
				 REFERENCES [Sales].[SalesTerritory] ([TerritoryID]) 
    ALTER TABLE [PERSON].[STATEPROVINCE] 
				CHECK CONSTRAINT [FK_StateProvince_SalesTerritory_TerritoryID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesTerritory.TerritoryID.', 
		@level0type='schema',
		@level0name='Person', 
		@level1type='TABLE', 
		@level1name='StateProvince', 
		@level2type='CONSTRAINT',
		@level2name='FK_StateProvince_SalesTerritory_TerritoryID'
    Print 'Added Extended Property MS_Description to FK_StateProvince_SalesTerritory_TerritoryID'
    Print 'Created Foreign Key Constraint [FK_StateProvince_SalesTerritory_TerritoryID]'
END
GO

-- Create Foreign Key Constraint [FK_BillOfMaterials_Product_ComponentID]
BEGIN
    ALTER TABLE [PRODUCTION].[BILLOFMATERIALS] WITH CHECK 
                 ADD CONSTRAINT [FK_BillOfMaterials_Product_ComponentID] 
				 FOREIGN KEY([ComponentID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PRODUCTION].[BILLOFMATERIALS] 
				CHECK CONSTRAINT [FK_BillOfMaterials_Product_ComponentID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ComponentID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='BillOfMaterials', 
		@level2type='CONSTRAINT',
		@level2name='FK_BillOfMaterials_Product_ComponentID'
    Print 'Added Extended Property MS_Description to FK_BillOfMaterials_Product_ComponentID'
    Print 'Created Foreign Key Constraint [FK_BillOfMaterials_Product_ComponentID]'
END
GO

-- Create Foreign Key Constraint [FK_BillOfMaterials_Product_ProductAssemblyID]
BEGIN
    ALTER TABLE [PRODUCTION].[BILLOFMATERIALS] WITH CHECK 
                 ADD CONSTRAINT [FK_BillOfMaterials_Product_ProductAssemblyID] 
				 FOREIGN KEY([ProductAssemblyID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PRODUCTION].[BILLOFMATERIALS] 
				CHECK CONSTRAINT [FK_BillOfMaterials_Product_ProductAssemblyID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductAssemblyID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='BillOfMaterials', 
		@level2type='CONSTRAINT',
		@level2name='FK_BillOfMaterials_Product_ProductAssemblyID'
    Print 'Added Extended Property MS_Description to FK_BillOfMaterials_Product_ProductAssemblyID'
    Print 'Created Foreign Key Constraint [FK_BillOfMaterials_Product_ProductAssemblyID]'
END
GO

-- Create Foreign Key Constraint [FK_BillOfMaterials_UnitMeasure_UnitMeasureCode]
BEGIN
    ALTER TABLE [PRODUCTION].[BILLOFMATERIALS] WITH CHECK 
                 ADD CONSTRAINT [FK_BillOfMaterials_UnitMeasure_UnitMeasureCode] 
				 FOREIGN KEY([UnitMeasureCode])
				 REFERENCES [Production].[UnitMeasure] ([UnitMeasureCode]) 
    ALTER TABLE [PRODUCTION].[BILLOFMATERIALS] 
				CHECK CONSTRAINT [FK_BillOfMaterials_UnitMeasure_UnitMeasureCode]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing UnitMeasure.UnitMeasureCode.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='BillOfMaterials', 
		@level2type='CONSTRAINT',
		@level2name='FK_BillOfMaterials_UnitMeasure_UnitMeasureCode'
    Print 'Added Extended Property MS_Description to FK_BillOfMaterials_UnitMeasure_UnitMeasureCode'
    Print 'Created Foreign Key Constraint [FK_BillOfMaterials_UnitMeasure_UnitMeasureCode]'
END
GO

-- Create Foreign Key Constraint [FK_SpecialOfferProduct_Product_ProductID]
BEGIN
    ALTER TABLE [SALES].[SPECIALOFFERPRODUCT] WITH CHECK 
                 ADD CONSTRAINT [FK_SpecialOfferProduct_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [SALES].[SPECIALOFFERPRODUCT] 
				CHECK CONSTRAINT [FK_SpecialOfferProduct_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SpecialOfferProduct', 
		@level2type='CONSTRAINT',
		@level2name='FK_SpecialOfferProduct_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_SpecialOfferProduct_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_SpecialOfferProduct_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_SpecialOfferProduct_SpecialOffer_SpecialOfferID]
BEGIN
    ALTER TABLE [SALES].[SPECIALOFFERPRODUCT] WITH CHECK 
                 ADD CONSTRAINT [FK_SpecialOfferProduct_SpecialOffer_SpecialOfferID] 
				 FOREIGN KEY([SpecialOfferID])
				 REFERENCES [Sales].[SpecialOffer] ([SpecialOfferID]) 
    ALTER TABLE [SALES].[SPECIALOFFERPRODUCT] 
				CHECK CONSTRAINT [FK_SpecialOfferProduct_SpecialOffer_SpecialOfferID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SpecialOffer.SpecialOfferID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='SpecialOfferProduct', 
		@level2type='CONSTRAINT',
		@level2name='FK_SpecialOfferProduct_SpecialOffer_SpecialOfferID'
    Print 'Added Extended Property MS_Description to FK_SpecialOfferProduct_SpecialOffer_SpecialOfferID'
    Print 'Created Foreign Key Constraint [FK_SpecialOfferProduct_SpecialOffer_SpecialOfferID]'
END
GO

-- Create Foreign Key Constraint [FK_ShoppingCartItem_Product_ProductID]
BEGIN
    ALTER TABLE [SALES].[SHOPPINGCARTITEM] WITH CHECK 
                 ADD CONSTRAINT [FK_ShoppingCartItem_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [SALES].[SHOPPINGCARTITEM] 
				CHECK CONSTRAINT [FK_ShoppingCartItem_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='ShoppingCartItem', 
		@level2type='CONSTRAINT',
		@level2name='FK_ShoppingCartItem_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_ShoppingCartItem_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_ShoppingCartItem_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductVendor_Product_ProductID]
BEGIN
    ALTER TABLE [PURCHASING].[PRODUCTVENDOR] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductVendor_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PURCHASING].[PRODUCTVENDOR] 
				CHECK CONSTRAINT [FK_ProductVendor_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='ProductVendor', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductVendor_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_ProductVendor_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_ProductVendor_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductVendor_UnitMeasure_UnitMeasureCode]
BEGIN
    ALTER TABLE [PURCHASING].[PRODUCTVENDOR] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductVendor_UnitMeasure_UnitMeasureCode] 
				 FOREIGN KEY([UnitMeasureCode])
				 REFERENCES [Production].[UnitMeasure] ([UnitMeasureCode]) 
    ALTER TABLE [PURCHASING].[PRODUCTVENDOR] 
				CHECK CONSTRAINT [FK_ProductVendor_UnitMeasure_UnitMeasureCode]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing UnitMeasure.UnitMeasureCode.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='ProductVendor', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductVendor_UnitMeasure_UnitMeasureCode'
    Print 'Added Extended Property MS_Description to FK_ProductVendor_UnitMeasure_UnitMeasureCode'
    Print 'Created Foreign Key Constraint [FK_ProductVendor_UnitMeasure_UnitMeasureCode]'
END
GO

-- Create Foreign Key Constraint [FK_ProductVendor_Vendor_VendorID]
BEGIN
    ALTER TABLE [PURCHASING].[PRODUCTVENDOR] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductVendor_Vendor_VendorID] 
				 FOREIGN KEY([VendorID])
				 REFERENCES [Purchasing].[Vendor] ([VendorID]) 
    ALTER TABLE [PURCHASING].[PRODUCTVENDOR] 
				CHECK CONSTRAINT [FK_ProductVendor_Vendor_VendorID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Vendor.VendorID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='ProductVendor', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductVendor_Vendor_VendorID'
    Print 'Added Extended Property MS_Description to FK_ProductVendor_Vendor_VendorID'
    Print 'Created Foreign Key Constraint [FK_ProductVendor_Vendor_VendorID]'
END
GO

-- Create Foreign Key Constraint [FK_WorkOrderRouting_WorkOrder_WorkOrderID]
BEGIN
    ALTER TABLE [PRODUCTION].[WORKORDERROUTING] WITH CHECK 
                 ADD CONSTRAINT [FK_WorkOrderRouting_WorkOrder_WorkOrderID] 
				 FOREIGN KEY([WorkOrderID])
				 REFERENCES [Production].[WorkOrder] ([WorkOrderID]) 
    ALTER TABLE [PRODUCTION].[WORKORDERROUTING] 
				CHECK CONSTRAINT [FK_WorkOrderRouting_WorkOrder_WorkOrderID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing WorkOrder.WorkOrderID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='WorkOrderRouting', 
		@level2type='CONSTRAINT',
		@level2name='FK_WorkOrderRouting_WorkOrder_WorkOrderID'
    Print 'Added Extended Property MS_Description to FK_WorkOrderRouting_WorkOrder_WorkOrderID'
    Print 'Created Foreign Key Constraint [FK_WorkOrderRouting_WorkOrder_WorkOrderID]'
END
GO

-- Create Foreign Key Constraint [FK_WorkOrderRouting_Location_LocationID]
BEGIN
    ALTER TABLE [PRODUCTION].[WORKORDERROUTING] WITH CHECK 
                 ADD CONSTRAINT [FK_WorkOrderRouting_Location_LocationID] 
				 FOREIGN KEY([LocationID])
				 REFERENCES [Production].[Location] ([LocationID]) 
    ALTER TABLE [PRODUCTION].[WORKORDERROUTING] 
				CHECK CONSTRAINT [FK_WorkOrderRouting_Location_LocationID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Location.LocationID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='WorkOrderRouting', 
		@level2type='CONSTRAINT',
		@level2name='FK_WorkOrderRouting_Location_LocationID'
    Print 'Added Extended Property MS_Description to FK_WorkOrderRouting_Location_LocationID'
    Print 'Created Foreign Key Constraint [FK_WorkOrderRouting_Location_LocationID]'
END
GO

-- Create Foreign Key Constraint [FK_WorkOrder_Product_ProductID]
BEGIN
    ALTER TABLE [PRODUCTION].[WORKORDER] WITH CHECK 
                 ADD CONSTRAINT [FK_WorkOrder_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PRODUCTION].[WORKORDER] 
				CHECK CONSTRAINT [FK_WorkOrder_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='WorkOrder', 
		@level2type='CONSTRAINT',
		@level2name='FK_WorkOrder_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_WorkOrder_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_WorkOrder_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_WorkOrder_ScrapReason_ScrapReasonID]
BEGIN
    ALTER TABLE [PRODUCTION].[WORKORDER] WITH CHECK 
                 ADD CONSTRAINT [FK_WorkOrder_ScrapReason_ScrapReasonID] 
				 FOREIGN KEY([ScrapReasonID])
				 REFERENCES [Production].[ScrapReason] ([ScrapReasonID]) 
    ALTER TABLE [PRODUCTION].[WORKORDER] 
				CHECK CONSTRAINT [FK_WorkOrder_ScrapReason_ScrapReasonID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ScrapReason.ScrapReasonID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='WorkOrder', 
		@level2type='CONSTRAINT',
		@level2name='FK_WorkOrder_ScrapReason_ScrapReasonID'
    Print 'Added Extended Property MS_Description to FK_WorkOrder_ScrapReason_ScrapReasonID'
    Print 'Created Foreign Key Constraint [FK_WorkOrder_ScrapReason_ScrapReasonID]'
END
GO

-- Create Foreign Key Constraint [FK_TransactionHistory_Product_ProductID]
BEGIN
    ALTER TABLE [PRODUCTION].[TRANSACTIONHISTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_TransactionHistory_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PRODUCTION].[TRANSACTIONHISTORY] 
				CHECK CONSTRAINT [FK_TransactionHistory_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='TransactionHistory', 
		@level2type='CONSTRAINT',
		@level2name='FK_TransactionHistory_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_TransactionHistory_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_TransactionHistory_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductReview_Product_ProductID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTREVIEW] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductReview_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTREVIEW] 
				CHECK CONSTRAINT [FK_ProductReview_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductReview', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductReview_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_ProductReview_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_ProductReview_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductProductPhoto_Product_ProductID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTPRODUCTPHOTO] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductProductPhoto_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTPRODUCTPHOTO] 
				CHECK CONSTRAINT [FK_ProductProductPhoto_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductProductPhoto', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductProductPhoto_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_ProductProductPhoto_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_ProductProductPhoto_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductProductPhoto_ProductPhoto_ProductPhotoID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTPRODUCTPHOTO] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductProductPhoto_ProductPhoto_ProductPhotoID] 
				 FOREIGN KEY([ProductPhotoID])
				 REFERENCES [Production].[ProductPhoto] ([ProductPhotoID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTPRODUCTPHOTO] 
				CHECK CONSTRAINT [FK_ProductProductPhoto_ProductPhoto_ProductPhotoID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ProductPhoto.ProductPhotoID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductProductPhoto', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductProductPhoto_ProductPhoto_ProductPhotoID'
    Print 'Added Extended Property MS_Description to FK_ProductProductPhoto_ProductPhoto_ProductPhotoID'
    Print 'Created Foreign Key Constraint [FK_ProductProductPhoto_ProductPhoto_ProductPhotoID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductListPriceHistory_Product_ProductID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTLISTPRICEHISTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductListPriceHistory_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTLISTPRICEHISTORY] 
				CHECK CONSTRAINT [FK_ProductListPriceHistory_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductListPriceHistory', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductListPriceHistory_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_ProductListPriceHistory_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_ProductListPriceHistory_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductInventory_Product_ProductID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTINVENTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductInventory_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTINVENTORY] 
				CHECK CONSTRAINT [FK_ProductInventory_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductInventory', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductInventory_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_ProductInventory_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_ProductInventory_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductInventory_Location_LocationID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTINVENTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductInventory_Location_LocationID] 
				 FOREIGN KEY([LocationID])
				 REFERENCES [Production].[Location] ([LocationID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTINVENTORY] 
				CHECK CONSTRAINT [FK_ProductInventory_Location_LocationID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Location.LocationID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductInventory', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductInventory_Location_LocationID'
    Print 'Added Extended Property MS_Description to FK_ProductInventory_Location_LocationID'
    Print 'Created Foreign Key Constraint [FK_ProductInventory_Location_LocationID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductDocument_Product_ProductID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTDOCUMENT] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductDocument_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTDOCUMENT] 
				CHECK CONSTRAINT [FK_ProductDocument_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductDocument', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductDocument_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_ProductDocument_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_ProductDocument_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductDocument_Document_DocumentID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTDOCUMENT] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductDocument_Document_DocumentID] 
				 FOREIGN KEY([DocumentID])
				 REFERENCES [Production].[Document] ([DocumentID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTDOCUMENT] 
				CHECK CONSTRAINT [FK_ProductDocument_Document_DocumentID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Document.DocumentID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductDocument', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductDocument_Document_DocumentID'
    Print 'Added Extended Property MS_Description to FK_ProductDocument_Document_DocumentID'
    Print 'Created Foreign Key Constraint [FK_ProductDocument_Document_DocumentID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductCostHistory_Product_ProductID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTCOSTHISTORY] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductCostHistory_Product_ProductID] 
				 FOREIGN KEY([ProductID])
				 REFERENCES [Production].[Product] ([ProductID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTCOSTHISTORY] 
				CHECK CONSTRAINT [FK_ProductCostHistory_Product_ProductID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Product.ProductID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductCostHistory', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductCostHistory_Product_ProductID'
    Print 'Added Extended Property MS_Description to FK_ProductCostHistory_Product_ProductID'
    Print 'Created Foreign Key Constraint [FK_ProductCostHistory_Product_ProductID]'
END
GO

-- Create Foreign Key Constraint [FK_Product_ProductModel_ProductModelID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCT] WITH CHECK 
                 ADD CONSTRAINT [FK_Product_ProductModel_ProductModelID] 
				 FOREIGN KEY([ProductModelID])
				 REFERENCES [Production].[ProductModel] ([ProductModelID]) 
    ALTER TABLE [PRODUCTION].[PRODUCT] 
				CHECK CONSTRAINT [FK_Product_ProductModel_ProductModelID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ProductModel.ProductModelID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='Product', 
		@level2type='CONSTRAINT',
		@level2name='FK_Product_ProductModel_ProductModelID'
    Print 'Added Extended Property MS_Description to FK_Product_ProductModel_ProductModelID'
    Print 'Created Foreign Key Constraint [FK_Product_ProductModel_ProductModelID]'
END
GO

-- Create Foreign Key Constraint [FK_Product_ProductSubcategory_ProductSubcategoryID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCT] WITH CHECK 
                 ADD CONSTRAINT [FK_Product_ProductSubcategory_ProductSubcategoryID] 
				 FOREIGN KEY([ProductSubcategoryID])
				 REFERENCES [Production].[ProductSubcategory] ([ProductSubcategoryID]) 
    ALTER TABLE [PRODUCTION].[PRODUCT] 
				CHECK CONSTRAINT [FK_Product_ProductSubcategory_ProductSubcategoryID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ProductSubcategory.ProductSubcategoryID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='Product', 
		@level2type='CONSTRAINT',
		@level2name='FK_Product_ProductSubcategory_ProductSubcategoryID'
    Print 'Added Extended Property MS_Description to FK_Product_ProductSubcategory_ProductSubcategoryID'
    Print 'Created Foreign Key Constraint [FK_Product_ProductSubcategory_ProductSubcategoryID]'
END
GO

-- Create Foreign Key Constraint [FK_Product_UnitMeasure_SizeUnitMeasureCode]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCT] WITH CHECK 
                 ADD CONSTRAINT [FK_Product_UnitMeasure_SizeUnitMeasureCode] 
				 FOREIGN KEY([SizeUnitMeasureCode])
				 REFERENCES [Production].[UnitMeasure] ([UnitMeasureCode]) 
    ALTER TABLE [PRODUCTION].[PRODUCT] 
				CHECK CONSTRAINT [FK_Product_UnitMeasure_SizeUnitMeasureCode]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing UnitMeasure.UnitMeasureCode.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='Product', 
		@level2type='CONSTRAINT',
		@level2name='FK_Product_UnitMeasure_SizeUnitMeasureCode'
    Print 'Added Extended Property MS_Description to FK_Product_UnitMeasure_SizeUnitMeasureCode'
    Print 'Created Foreign Key Constraint [FK_Product_UnitMeasure_SizeUnitMeasureCode]'
END
GO

-- Create Foreign Key Constraint [FK_Product_UnitMeasure_WeightUnitMeasureCode]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCT] WITH CHECK 
                 ADD CONSTRAINT [FK_Product_UnitMeasure_WeightUnitMeasureCode] 
				 FOREIGN KEY([WeightUnitMeasureCode])
				 REFERENCES [Production].[UnitMeasure] ([UnitMeasureCode]) 
    ALTER TABLE [PRODUCTION].[PRODUCT] 
				CHECK CONSTRAINT [FK_Product_UnitMeasure_WeightUnitMeasureCode]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing UnitMeasure.UnitMeasureCode.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='Product', 
		@level2type='CONSTRAINT',
		@level2name='FK_Product_UnitMeasure_WeightUnitMeasureCode'
    Print 'Added Extended Property MS_Description to FK_Product_UnitMeasure_WeightUnitMeasureCode'
    Print 'Created Foreign Key Constraint [FK_Product_UnitMeasure_WeightUnitMeasureCode]'
END
GO

-- Create Foreign Key Constraint [FK_ProductModelIllustration_Illustration_IllustrationID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTMODELILLUSTRATION] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductModelIllustration_Illustration_IllustrationID] 
				 FOREIGN KEY([IllustrationID])
				 REFERENCES [Production].[Illustration] ([IllustrationID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTMODELILLUSTRATION] 
				CHECK CONSTRAINT [FK_ProductModelIllustration_Illustration_IllustrationID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Illustration.IllustrationID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductModelIllustration', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductModelIllustration_Illustration_IllustrationID'
    Print 'Added Extended Property MS_Description to FK_ProductModelIllustration_Illustration_IllustrationID'
    Print 'Created Foreign Key Constraint [FK_ProductModelIllustration_Illustration_IllustrationID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductModelIllustration_ProductModel_ProductModelID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTMODELILLUSTRATION] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductModelIllustration_ProductModel_ProductModelID] 
				 FOREIGN KEY([ProductModelID])
				 REFERENCES [Production].[ProductModel] ([ProductModelID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTMODELILLUSTRATION] 
				CHECK CONSTRAINT [FK_ProductModelIllustration_ProductModel_ProductModelID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ProductModel.ProductModelID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductModelIllustration', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductModelIllustration_ProductModel_ProductModelID'
    Print 'Added Extended Property MS_Description to FK_ProductModelIllustration_ProductModel_ProductModelID'
    Print 'Created Foreign Key Constraint [FK_ProductModelIllustration_ProductModel_ProductModelID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductModelProductDescriptionCulture_Culture_CultureID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTMODELPRODUCTDESCRIPTIONCULTURE] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductModelProductDescriptionCulture_Culture_CultureID] 
				 FOREIGN KEY([CultureID])
				 REFERENCES [Production].[Culture] ([CultureID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTMODELPRODUCTDESCRIPTIONCULTURE] 
				CHECK CONSTRAINT [FK_ProductModelProductDescriptionCulture_Culture_CultureID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Culture.CultureID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductModelProductDescriptionCulture', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductModelProductDescriptionCulture_Culture_CultureID'
    Print 'Added Extended Property MS_Description to FK_ProductModelProductDescriptionCulture_Culture_CultureID'
    Print 'Created Foreign Key Constraint [FK_ProductModelProductDescriptionCulture_Culture_CultureID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTMODELPRODUCTDESCRIPTIONCULTURE] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID] 
				 FOREIGN KEY([ProductDescriptionID])
				 REFERENCES [Production].[ProductDescription] ([ProductDescriptionID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTMODELPRODUCTDESCRIPTIONCULTURE] 
				CHECK CONSTRAINT [FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ProductDescription.ProductDescriptionID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductModelProductDescriptionCulture', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID'
    Print 'Added Extended Property MS_Description to ' + 
		  'FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID'
    Print 'Created Foreign Key Constraint ' + 
		  '[FK_ProductModelProductDescriptionCulture_ProductDescription_ProductDescriptionID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTMODELPRODUCTDESCRIPTIONCULTURE] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID] 
				 FOREIGN KEY([ProductModelID])
				 REFERENCES [Production].[ProductModel] ([ProductModelID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTMODELPRODUCTDESCRIPTIONCULTURE] 
				CHECK CONSTRAINT [FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ProductModel.ProductModelID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductModelProductDescriptionCulture', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID'
    Print 'Added Extended Property MS_Description to ' + 
	      'FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID'
    Print 'Created Foreign Key Constraint ' + 
	      '[FK_ProductModelProductDescriptionCulture_ProductModel_ProductModelID]'
END
GO

-- Create Foreign Key Constraint [FK_ProductSubcategory_ProductCategory_ProductCategoryID]
BEGIN
    ALTER TABLE [PRODUCTION].[PRODUCTSUBCATEGORY] WITH CHECK 
                 ADD CONSTRAINT [FK_ProductSubcategory_ProductCategory_ProductCategoryID] 
				 FOREIGN KEY([ProductCategoryID])
				 REFERENCES [Production].[ProductCategory] ([ProductCategoryID]) 
    ALTER TABLE [PRODUCTION].[PRODUCTSUBCATEGORY] 
				CHECK CONSTRAINT [FK_ProductSubcategory_ProductCategory_ProductCategoryID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ProductCategory.ProductCategoryID.', 
		@level0type='schema',
		@level0name='Production', 
		@level1type='TABLE', 
		@level1name='ProductSubcategory', 
		@level2type='CONSTRAINT',
		@level2name='FK_ProductSubcategory_ProductCategory_ProductCategoryID'
    Print 'Added Extended Property MS_Description to FK_ProductSubcategory_ProductCategory_ProductCategoryID'
    Print 'Created Foreign Key Constraint [FK_ProductSubcategory_ProductCategory_ProductCategoryID]'
END
GO

-- Create Foreign Key Constraint [FK_VendorContact_Contact_ContactID]
BEGIN
    ALTER TABLE [PURCHASING].[VENDORCONTACT] WITH CHECK 
                 ADD CONSTRAINT [FK_VendorContact_Contact_ContactID] 
				 FOREIGN KEY([ContactID])
				 REFERENCES [Person].[Contact] ([ContactID]) 
    ALTER TABLE [PURCHASING].[VENDORCONTACT] 
				CHECK CONSTRAINT [FK_VendorContact_Contact_ContactID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Contact.ContactID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='VendorContact', 
		@level2type='CONSTRAINT',
		@level2name='FK_VendorContact_Contact_ContactID'
    Print 'Added Extended Property MS_Description to FK_VendorContact_Contact_ContactID'
    Print 'Created Foreign Key Constraint [FK_VendorContact_Contact_ContactID]'
END
GO

-- Create Foreign Key Constraint [FK_VendorContact_ContactType_ContactTypeID]
BEGIN
    ALTER TABLE [PURCHASING].[VENDORCONTACT] WITH CHECK 
                 ADD CONSTRAINT [FK_VendorContact_ContactType_ContactTypeID] 
				 FOREIGN KEY([ContactTypeID])
				 REFERENCES [Person].[ContactType] ([ContactTypeID]) 
    ALTER TABLE [PURCHASING].[VENDORCONTACT] 
				CHECK CONSTRAINT [FK_VendorContact_ContactType_ContactTypeID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing ContactType.ContactTypeID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='VendorContact', 
		@level2type='CONSTRAINT',
		@level2name='FK_VendorContact_ContactType_ContactTypeID'
    Print 'Added Extended Property MS_Description to FK_VendorContact_ContactType_ContactTypeID'
    Print 'Created Foreign Key Constraint [FK_VendorContact_ContactType_ContactTypeID]'
END
GO

-- Create Foreign Key Constraint [FK_VendorContact_Vendor_VendorID]
BEGIN
    ALTER TABLE [PURCHASING].[VENDORCONTACT] WITH CHECK 
                 ADD CONSTRAINT [FK_VendorContact_Vendor_VendorID] 
				 FOREIGN KEY([VendorID])
				 REFERENCES [Purchasing].[Vendor] ([VendorID]) 
    ALTER TABLE [PURCHASING].[VENDORCONTACT] 
				CHECK CONSTRAINT [FK_VendorContact_Vendor_VendorID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Vendor.VendorID.', 
		@level0type='schema',
		@level0name='Purchasing', 
		@level1type='TABLE', 
		@level1name='VendorContact', 
		@level2type='CONSTRAINT',
		@level2name='FK_VendorContact_Vendor_VendorID'
    Print 'Added Extended Property MS_Description to FK_VendorContact_Vendor_VendorID'
    Print 'Created Foreign Key Constraint [FK_VendorContact_Vendor_VendorID]'
END
GO

-- Create Foreign Key Constraint [FK_ContactCreditCard_Contact_ContactID]
BEGIN
    ALTER TABLE [SALES].[CONTACTCREDITCARD] WITH CHECK 
                 ADD CONSTRAINT [FK_ContactCreditCard_Contact_ContactID] 
				 FOREIGN KEY([ContactID])
				 REFERENCES [Person].[Contact] ([ContactID]) 
    ALTER TABLE [SALES].[CONTACTCREDITCARD] 
				CHECK CONSTRAINT [FK_ContactCreditCard_Contact_ContactID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Contact.ContactID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='ContactCreditCard', 
		@level2type='CONSTRAINT',
		@level2name='FK_ContactCreditCard_Contact_ContactID'
    Print 'Added Extended Property MS_Description to FK_ContactCreditCard_Contact_ContactID'
    Print 'Created Foreign Key Constraint [FK_ContactCreditCard_Contact_ContactID]'
END
GO

-- Create Foreign Key Constraint [FK_ContactCreditCard_CreditCard_CreditCardID]
BEGIN
    ALTER TABLE [SALES].[CONTACTCREDITCARD] WITH CHECK 
                 ADD CONSTRAINT [FK_ContactCreditCard_CreditCard_CreditCardID] 
				 FOREIGN KEY([CreditCardID])
				 REFERENCES [Sales].[CreditCard] ([CreditCardID]) 
    ALTER TABLE [SALES].[CONTACTCREDITCARD] 
				CHECK CONSTRAINT [FK_ContactCreditCard_CreditCard_CreditCardID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing CreditCard.CreditCardID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='ContactCreditCard', 
		@level2type='CONSTRAINT',
		@level2name='FK_ContactCreditCard_CreditCard_CreditCardID'
    Print 'Added Extended Property MS_Description to FK_ContactCreditCard_CreditCard_CreditCardID'
    Print 'Created Foreign Key Constraint [FK_ContactCreditCard_CreditCard_CreditCardID]'
END
GO

-- Create Foreign Key Constraint [FK_CountryRegionCurrency_CountryRegion_CountryRegionCode]
BEGIN
    ALTER TABLE [SALES].[COUNTRYREGIONCURRENCY] WITH CHECK 
                 ADD CONSTRAINT [FK_CountryRegionCurrency_CountryRegion_CountryRegionCode] 
				 FOREIGN KEY([CountryRegionCode])
				 REFERENCES [Person].[CountryRegion] ([CountryRegionCode]) 
    ALTER TABLE [SALES].[COUNTRYREGIONCURRENCY] 
				CHECK CONSTRAINT [FK_CountryRegionCurrency_CountryRegion_CountryRegionCode]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing CountryRegion.CountryRegionCode.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='CountryRegionCurrency', 
		@level2type='CONSTRAINT',
		@level2name='FK_CountryRegionCurrency_CountryRegion_CountryRegionCode'
    Print 'Added Extended Property MS_Description to FK_CountryRegionCurrency_CountryRegion_CountryRegionCode'
    Print 'Created Foreign Key Constraint [FK_CountryRegionCurrency_CountryRegion_CountryRegionCode]'
END
GO

-- Create Foreign Key Constraint [FK_CountryRegionCurrency_Currency_CurrencyCode]
BEGIN
    ALTER TABLE [SALES].[COUNTRYREGIONCURRENCY] WITH CHECK 
                 ADD CONSTRAINT [FK_CountryRegionCurrency_Currency_CurrencyCode] 
				 FOREIGN KEY([CurrencyCode])
				 REFERENCES [Sales].[Currency] ([CurrencyCode]) 
    ALTER TABLE [SALES].[COUNTRYREGIONCURRENCY] 
				CHECK CONSTRAINT [FK_CountryRegionCurrency_Currency_CurrencyCode]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Currency.CurrencyCode.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='CountryRegionCurrency', 
		@level2type='CONSTRAINT',
		@level2name='FK_CountryRegionCurrency_Currency_CurrencyCode'
    Print 'Added Extended Property MS_Description to FK_CountryRegionCurrency_Currency_CurrencyCode'
    Print 'Created Foreign Key Constraint [FK_CountryRegionCurrency_Currency_CurrencyCode]'
END
GO

-- Create Foreign Key Constraint [FK_CurrencyRate_Currency_FromCurrencyCode]
BEGIN
    ALTER TABLE [SALES].[CURRENCYRATE] WITH CHECK 
                 ADD CONSTRAINT [FK_CurrencyRate_Currency_FromCurrencyCode] 
				 FOREIGN KEY([FromCurrencyCode])
				 REFERENCES [Sales].[Currency] ([CurrencyCode]) 
    ALTER TABLE [SALES].[CURRENCYRATE] 
				CHECK CONSTRAINT [FK_CurrencyRate_Currency_FromCurrencyCode]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Currency.FromCurrencyCode.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='CurrencyRate', 
		@level2type='CONSTRAINT',
		@level2name='FK_CurrencyRate_Currency_FromCurrencyCode'
    Print 'Added Extended Property MS_Description to FK_CurrencyRate_Currency_FromCurrencyCode'
    Print 'Created Foreign Key Constraint [FK_CurrencyRate_Currency_FromCurrencyCode]'
END
GO

-- Create Foreign Key Constraint [FK_CurrencyRate_Currency_ToCurrencyCode]
BEGIN
    ALTER TABLE [SALES].[CURRENCYRATE] WITH CHECK 
                 ADD CONSTRAINT [FK_CurrencyRate_Currency_ToCurrencyCode] 
				 FOREIGN KEY([ToCurrencyCode])
				 REFERENCES [Sales].[Currency] ([CurrencyCode]) 
    ALTER TABLE [SALES].[CURRENCYRATE] 
				CHECK CONSTRAINT [FK_CurrencyRate_Currency_ToCurrencyCode]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Currency.ToCurrencyCode.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='CurrencyRate', 
		@level2type='CONSTRAINT',
		@level2name='FK_CurrencyRate_Currency_ToCurrencyCode'
    Print 'Added Extended Property MS_Description to FK_CurrencyRate_Currency_ToCurrencyCode'
    Print 'Created Foreign Key Constraint [FK_CurrencyRate_Currency_ToCurrencyCode]'
END
GO

-- Create Foreign Key Constraint [FK_Individual_Customer_CustomerID]
BEGIN
    ALTER TABLE [SALES].[INDIVIDUAL] WITH CHECK 
                 ADD CONSTRAINT [FK_Individual_Customer_CustomerID] 
				 FOREIGN KEY([CustomerID])
				 REFERENCES [Sales].[Customer] ([CustomerID]) 
    ALTER TABLE [SALES].[INDIVIDUAL] 
				CHECK CONSTRAINT [FK_Individual_Customer_CustomerID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Customer.CustomerID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='Individual', 
		@level2type='CONSTRAINT',
		@level2name='FK_Individual_Customer_CustomerID'
    Print 'Added Extended Property MS_Description to FK_Individual_Customer_CustomerID'
    Print 'Created Foreign Key Constraint [FK_Individual_Customer_CustomerID]'
END
GO

-- Create Foreign Key Constraint [FK_Individual_Contact_ContactID]
BEGIN
    ALTER TABLE [SALES].[INDIVIDUAL] WITH CHECK 
                 ADD CONSTRAINT [FK_Individual_Contact_ContactID] 
				 FOREIGN KEY([ContactID])
				 REFERENCES [Person].[Contact] ([ContactID]) 
    ALTER TABLE [SALES].[INDIVIDUAL] 
				CHECK CONSTRAINT [FK_Individual_Contact_ContactID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing Contact.ContactID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='Individual', 
		@level2type='CONSTRAINT',
		@level2name='FK_Individual_Contact_ContactID'
    Print 'Added Extended Property MS_Description to FK_Individual_Contact_ContactID'
    Print 'Created Foreign Key Constraint [FK_Individual_Contact_ContactID]'
END
GO

-- Create Foreign Key Constraint [FK_Customer_SalesTerritory_TerritoryID]
BEGIN
    ALTER TABLE [SALES].[CUSTOMER] WITH CHECK 
                 ADD CONSTRAINT [FK_Customer_SalesTerritory_TerritoryID] 
				 FOREIGN KEY([TerritoryID])
				 REFERENCES [Sales].[SalesTerritory] ([TerritoryID]) 
    ALTER TABLE [SALES].[CUSTOMER] 
				CHECK CONSTRAINT [FK_Customer_SalesTerritory_TerritoryID]
    EXEC sys.sp_addextendedproperty @name='MS_Description', 
		@value='Foreign key constraint referencing SalesTerritory.TerritoryID.', 
		@level0type='schema',
		@level0name='Sales', 
		@level1type='TABLE', 
		@level1name='Customer', 
		@level2type='CONSTRAINT',
		@level2name='FK_Customer_SalesTerritory_TerritoryID'
    Print 'Added Extended Property MS_Description to FK_Customer_SalesTerritory_TerritoryID'
    Print 'Created Foreign Key Constraint [FK_Customer_SalesTerritory_TerritoryID]'
END
GO

About the Author

Joe Kunk is a Microsoft MVP in Visual Basic, three-time president of the Greater Lansing User Group for .NET, and developer for Dart Container Corporation of Mason, Michigan. He's been developing software for over 30 years and has worked in the education, government, financial and manufacturing industries. Kunk's co-authored the book "Professional DevExpress ASP.NET Controls" (Wrox Programmer to Programmer, 2009). He can be reached via email at [email protected].

comments powered by Disqus

Featured

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube