BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Transactions for previous years.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Transactions for previous years.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; COLUMN = TransactionID;
---------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'COLUMN', N'TransactionID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for TransactionHistoryArchive records.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'TransactionID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for TransactionHistoryArchive records.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'TransactionID'
END
GO
-----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; COLUMN = ProductID;
-----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'COLUMN', N'ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Product identification number. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Product identification number. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'ProductID'
END
GO
------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; COLUMN = ReferenceOrderID;
------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'COLUMN', N'ReferenceOrderID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Purchase order, sales order, or work order identification number.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'ReferenceOrderID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Purchase order, sales order, or work order identification number.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'ReferenceOrderID'
END
GO
----------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; COLUMN = ReferenceOrderLineID;
----------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'COLUMN', N'ReferenceOrderLineID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Line number associated with the purchase order, sales order, or work order.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'ReferenceOrderLineID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Line number associated with the purchase order, sales order, or work order.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'ReferenceOrderLineID'
END
GO
-----------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; COLUMN = TransactionDate;
-----------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'COLUMN', N'TransactionDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time of the transaction.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'TransactionDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time of the transaction.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'TransactionDate'
END
GO
-----------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; COLUMN = TransactionType;
-----------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'COLUMN', N'TransactionType'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'W = Work Order, S = Sales Order, P = Purchase Order', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'TransactionType'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'W = Work Order, S = Sales Order, P = Purchase Order', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'TransactionType'
END
GO
----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; COLUMN = Quantity;
----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'COLUMN', N'Quantity'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Product quantity.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'Quantity'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Product quantity.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'Quantity'
END
GO
------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; COLUMN = ActualCost;
------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'COLUMN', N'ActualCost'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Product cost.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'ActualCost'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Product cost.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'ActualCost'
END
GO
--------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; COLUMN = ModifiedDate;
--------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
---------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; INDEX = IX_TransactionHistoryArchive_ProductID;
---------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'INDEX', N'IX_TransactionHistoryArchive_ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'INDEX', @level2name = N'IX_TransactionHistoryArchive_ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'INDEX', @level2name = N'IX_TransactionHistoryArchive_ProductID'
END
GO
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; INDEX = IX_TransactionHistoryArchive_ReferenceOrderID_ReferenceOrderLineID;
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'INDEX', N'IX_TransactionHistoryArchive_ReferenceOrderID_ReferenceOrderLineID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'INDEX', @level2name = N'IX_TransactionHistoryArchive_ReferenceOrderID_ReferenceOrderLineID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'INDEX', @level2name = N'IX_TransactionHistoryArchive_ReferenceOrderID_ReferenceOrderLineID'
END
GO
------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = TransactionHistoryArchive; CONSTRAINT = PK_TransactionHistoryArchive_TransactionID;
------------------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'TransactionHistoryArchive', N'CONSTRAINT', N'PK_TransactionHistoryArchive_TransactionID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'CONSTRAINT', @level2name = N'PK_TransactionHistoryArchive_TransactionID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'TransactionHistoryArchive', @level2type = N'CONSTRAINT', @level2name = N'PK_TransactionHistoryArchive_TransactionID'
END
GO
--------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = UnitMeasure; 
--------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'UnitMeasure', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unit of measure lookup table.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unit of measure lookup table.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = UnitMeasure; COLUMN = UnitMeasureCode;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'UnitMeasure', N'COLUMN', N'UnitMeasureCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = N'COLUMN', @level2name = N'UnitMeasureCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = N'COLUMN', @level2name = N'UnitMeasureCode'
END
GO
----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = UnitMeasure; COLUMN = Name;
----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'UnitMeasure', N'COLUMN', N'Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unit of measure description.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = N'COLUMN', @level2name = N'Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unit of measure description.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = N'COLUMN', @level2name = N'Name'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = UnitMeasure; COLUMN = ModifiedDate;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'UnitMeasure', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = UnitMeasure; INDEX = AK_UnitMeasure_Name;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'UnitMeasure', N'INDEX', N'AK_UnitMeasure_Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = N'INDEX', @level2name = N'AK_UnitMeasure_Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = N'INDEX', @level2name = N'AK_UnitMeasure_Name'
END
GO
----------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = UnitMeasure; CONSTRAINT = PK_UnitMeasure_UnitMeasureCode;
----------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'UnitMeasure', N'CONSTRAINT', N'PK_UnitMeasure_UnitMeasureCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = N'CONSTRAINT', @level2name = N'PK_UnitMeasure_UnitMeasureCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'UnitMeasure', @level2type = N'CONSTRAINT', @level2name = N'PK_UnitMeasure_UnitMeasureCode'
END
GO
------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; 
------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Manufacturing work orders.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Manufacturing work orders.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; COLUMN = WorkOrderID;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'COLUMN', N'WorkOrderID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for WorkOrder records.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'WorkOrderID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for WorkOrder records.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'WorkOrderID'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; COLUMN = ProductID;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'COLUMN', N'ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Product identification number. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Product identification number. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'ProductID'
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; COLUMN = OrderQty;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'COLUMN', N'OrderQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Product quantity to build.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'OrderQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Product quantity to build.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'OrderQty'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; COLUMN = StockedQty;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'COLUMN', N'StockedQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Quantity built and put in inventory.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'StockedQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Quantity built and put in inventory.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'StockedQty'
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; COLUMN = ScrappedQty;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'COLUMN', N'ScrappedQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Quantity that failed inspection.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'ScrappedQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Quantity that failed inspection.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'ScrappedQty'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; COLUMN = StartDate;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'COLUMN', N'StartDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Work order start date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'StartDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Work order start date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'StartDate'
END
GO
-----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; COLUMN = EndDate;
-----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'COLUMN', N'EndDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Work order end date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'EndDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Work order end date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'EndDate'
END
GO
-----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; COLUMN = DueDate;
-----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'COLUMN', N'DueDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Work order due date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'DueDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Work order due date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'DueDate'
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; COLUMN = ScrapReasonID;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'COLUMN', N'ScrapReasonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Reason for inspection failure.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'ScrapReasonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Reason for inspection failure.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'ScrapReasonID'
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; COLUMN = ModifiedDate;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
-------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; INDEX = IX_WorkOrder_ProductID;
-------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'INDEX', N'IX_WorkOrder_ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'INDEX', @level2name = N'IX_WorkOrder_ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'INDEX', @level2name = N'IX_WorkOrder_ProductID'
END
GO
-----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; INDEX = IX_WorkOrder_ScrapReasonID;
-----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'INDEX', N'IX_WorkOrder_ScrapReasonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'INDEX', @level2name = N'IX_WorkOrder_ScrapReasonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'INDEX', @level2name = N'IX_WorkOrder_ScrapReasonID'
END
GO
--------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; CONSTRAINT = PK_WorkOrder_WorkOrderID;
--------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'CONSTRAINT', N'PK_WorkOrder_WorkOrderID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'CONSTRAINT', @level2name = N'PK_WorkOrder_WorkOrderID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'CONSTRAINT', @level2name = N'PK_WorkOrder_WorkOrderID'
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; TRIGGER = iWorkOrder;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'TRIGGER', N'iWorkOrder'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'AFTER INSERT trigger that inserts a row in the TransactionHistory table.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'TRIGGER', @level2name = N'iWorkOrder'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'AFTER INSERT trigger that inserts a row in the TransactionHistory table.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'TRIGGER', @level2name = N'iWorkOrder'
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrder; TRIGGER = uWorkOrder;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrder', N'TRIGGER', N'uWorkOrder'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'AFTER UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in the WorkOrder table.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'TRIGGER', @level2name = N'uWorkOrder'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'AFTER UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in the WorkOrder table.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrder', @level2type = N'TRIGGER', @level2name = N'uWorkOrder'
END
GO
-------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; 
-------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Work order details.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Work order details.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = WorkOrderID;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'WorkOrderID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to WorkOrder.WorkOrderID.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'WorkOrderID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to WorkOrder.WorkOrderID.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'WorkOrderID'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = ProductID;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ProductID'
END
GO
----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = OperationSequence;
----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'OperationSequence'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Indicates the manufacturing process sequence.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'OperationSequence'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Indicates the manufacturing process sequence.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'OperationSequence'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = LocationID;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'LocationID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Manufacturing location where the part is processed. Foreign key to Location.LocationID.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'LocationID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Manufacturing location where the part is processed. Foreign key to Location.LocationID.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'LocationID'
END
GO
-----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = ScheduledStartDate;
-----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'ScheduledStartDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Planned manufacturing start date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ScheduledStartDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Planned manufacturing start date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ScheduledStartDate'
END
GO
---------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = ScheduledEndDate;
---------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'ScheduledEndDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Planned manufacturing end date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ScheduledEndDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Planned manufacturing end date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ScheduledEndDate'
END
GO
--------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = ActualStartDate;
--------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'ActualStartDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Actual start date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ActualStartDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Actual start date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ActualStartDate'
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = ActualEndDate;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'ActualEndDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Actual end date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ActualEndDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Actual end date.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ActualEndDate'
END
GO
----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = ActualResourceHrs;
----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'ActualResourceHrs'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Number of manufacturing hours used.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ActualResourceHrs'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Number of manufacturing hours used.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ActualResourceHrs'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = PlannedCost;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'PlannedCost'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Estimated manufacturing cost.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'PlannedCost'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Estimated manufacturing cost.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'PlannedCost'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = ActualCost;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'ActualCost'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Actual manufacturing cost.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ActualCost'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Actual manufacturing cost.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ActualCost'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; COLUMN = ModifiedDate;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
---------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; INDEX = IX_WorkOrderRouting_ProductID;
---------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'INDEX', N'IX_WorkOrderRouting_ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'INDEX', @level2name = N'IX_WorkOrderRouting_ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'INDEX', @level2name = N'IX_WorkOrderRouting_ProductID'
END
GO
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Production; TABLE = WorkOrderRouting; CONSTRAINT = PK_WorkOrderRouting_WorkOrderID_ProductID_OperationSequence;
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'TABLE', N'WorkOrderRouting', N'CONSTRAINT', N'PK_WorkOrderRouting_WorkOrderID_ProductID_OperationSequence'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'CONSTRAINT', @level2name = N'PK_WorkOrderRouting_WorkOrderID_ProductID_OperationSequence'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'TABLE', @level1name = N'WorkOrderRouting', @level2type = N'CONSTRAINT', @level2name = N'PK_WorkOrderRouting_WorkOrderID_ProductID_OperationSequence'
END
GO
----------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; 
----------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping vendors with the products they supply.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping vendors with the products they supply.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = default, @level2name = default
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; COLUMN = ProductID;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'COLUMN', N'ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'ProductID'
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; COLUMN = VendorID;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'COLUMN', N'VendorID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Vendor.VendorID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'VendorID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Vendor.VendorID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'VendorID'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; COLUMN = AverageLeadTime;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'COLUMN', N'AverageLeadTime'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'The average span of time (in days) between placing an order with the vendor and receiving the purchased product.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'AverageLeadTime'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'The average span of time (in days) between placing an order with the vendor and receiving the purchased product.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'AverageLeadTime'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; COLUMN = StandardPrice;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'COLUMN', N'StandardPrice'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'The vendor's usual selling price.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'StandardPrice'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'The vendor's usual selling price.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'StandardPrice'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; COLUMN = LastReceiptCost;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'COLUMN', N'LastReceiptCost'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'The selling price when last purchased.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'LastReceiptCost'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'The selling price when last purchased.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'LastReceiptCost'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; COLUMN = LastReceiptDate;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'COLUMN', N'LastReceiptDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date the product was last received by the vendor.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'LastReceiptDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date the product was last received by the vendor.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'LastReceiptDate'
END
GO
-------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; COLUMN = MinOrderQty;
-------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'COLUMN', N'MinOrderQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'The maximum quantity that should be ordered.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'MinOrderQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'The maximum quantity that should be ordered.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'MinOrderQty'
END
GO
-------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; COLUMN = MaxOrderQty;
-------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'COLUMN', N'MaxOrderQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'The minimum quantity that should be ordered.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'MaxOrderQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'The minimum quantity that should be ordered.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'MaxOrderQty'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; COLUMN = OnOrderQty;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'COLUMN', N'OnOrderQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'The quantity currently on order.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'OnOrderQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'The quantity currently on order.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'OnOrderQty'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; COLUMN = UnitMeasureCode;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'COLUMN', N'UnitMeasureCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'The product's unit of measure.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'UnitMeasureCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'The product's unit of measure.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'UnitMeasureCode'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; COLUMN = ModifiedDate;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
---------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; INDEX = IX_ProductVendor_UnitMeasureCode;
---------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'INDEX', N'IX_ProductVendor_UnitMeasureCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'INDEX', @level2name = N'IX_ProductVendor_UnitMeasureCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'INDEX', @level2name = N'IX_ProductVendor_UnitMeasureCode'
END
GO
--------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; INDEX = IX_ProductVendor_VendorID;
--------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'INDEX', N'IX_ProductVendor_VendorID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'INDEX', @level2name = N'IX_ProductVendor_VendorID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'INDEX', @level2name = N'IX_ProductVendor_VendorID'
END
GO
-----------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ProductVendor; CONSTRAINT = PK_ProductVendor_ProductID_VendorID;
-----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ProductVendor', N'CONSTRAINT', N'PK_ProductVendor_ProductID_VendorID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'CONSTRAINT', @level2name = N'PK_ProductVendor_ProductID_VendorID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ProductVendor', @level2type = N'CONSTRAINT', @level2name = N'PK_ProductVendor_ProductID_VendorID'
END
GO
----------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; 
----------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Individual products associated with a specific purchase order. See PurchaseOrderHeader.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Individual products associated with a specific purchase order. See PurchaseOrderHeader.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = default, @level2name = default
END
GO
-----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; COLUMN = PurchaseOrderID;
-----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'COLUMN', N'PurchaseOrderID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to PurchaseOrderHeader.PurchaseOrderID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'PurchaseOrderID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to PurchaseOrderHeader.PurchaseOrderID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'PurchaseOrderID'
END
GO
-----------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; COLUMN = PurchaseOrderDetailID;
-----------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'COLUMN', N'PurchaseOrderDetailID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. One line number per purchased product.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'PurchaseOrderDetailID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. One line number per purchased product.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'PurchaseOrderDetailID'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; COLUMN = DueDate;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'COLUMN', N'DueDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date the product is expected to be received.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'DueDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date the product is expected to be received.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'DueDate'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; COLUMN = OrderQty;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'COLUMN', N'OrderQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Quantity ordered.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'OrderQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Quantity ordered.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'OrderQty'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; COLUMN = ProductID;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'COLUMN', N'ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Product identification number. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Product identification number. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'ProductID'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; COLUMN = UnitPrice;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'COLUMN', N'UnitPrice'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Vendor's selling price of a single product.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'UnitPrice'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Vendor's selling price of a single product.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'UnitPrice'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; COLUMN = LineTotal;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'COLUMN', N'LineTotal'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Per product subtotal. Computed as OrderQty * UnitPrice.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'LineTotal'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Per product subtotal. Computed as OrderQty * UnitPrice.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'LineTotal'
END
GO
-------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; COLUMN = ReceivedQty;
-------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'COLUMN', N'ReceivedQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Quantity actually received from the vendor.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'ReceivedQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Quantity actually received from the vendor.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'ReceivedQty'
END
GO
-------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; COLUMN = RejectedQty;
-------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'COLUMN', N'RejectedQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Quantity rejected during inspection.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'RejectedQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Quantity rejected during inspection.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'RejectedQty'
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; COLUMN = StockedQty;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'COLUMN', N'StockedQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Quantity accepted into inventory. Computed as ReceivedQty - RejectedQty.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'StockedQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Quantity accepted into inventory. Computed as ReceivedQty - RejectedQty.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'StockedQty'
END
GO
--------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; COLUMN = ModifiedDate;
--------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
---------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; INDEX = IX_PurchaseOrderDetail_ProductID;
---------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'INDEX', N'IX_PurchaseOrderDetail_ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'INDEX', @level2name = N'IX_PurchaseOrderDetail_ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'INDEX', @level2name = N'IX_PurchaseOrderDetail_ProductID'
END
GO
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; CONSTRAINT = PK_PurchaseOrderDetail_PurchaseOrderID_PurchaseOrderDetailID;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'CONSTRAINT', N'PK_PurchaseOrderDetail_PurchaseOrderID_PurchaseOrderDetailID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'CONSTRAINT', @level2name = N'PK_PurchaseOrderDetail_PurchaseOrderID_PurchaseOrderDetailID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'CONSTRAINT', @level2name = N'PK_PurchaseOrderDetail_PurchaseOrderID_PurchaseOrderDetailID'
END
GO
-----------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; TRIGGER = iPurchaseOrderDetail;
-----------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'TRIGGER', N'iPurchaseOrderDetail'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'AFTER INSERT trigger that inserts a row in the TransactionHistory table and updates the PurchaseOrderHeader.SubTotal column.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'TRIGGER', @level2name = N'iPurchaseOrderDetail'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'AFTER INSERT trigger that inserts a row in the TransactionHistory table and updates the PurchaseOrderHeader.SubTotal column.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'TRIGGER', @level2name = N'iPurchaseOrderDetail'
END
GO
-----------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderDetail; TRIGGER = uPurchaseOrderDetail;
-----------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderDetail', N'TRIGGER', N'uPurchaseOrderDetail'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'AFTER UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in PurchaseOrderDetail and updates the PurchaseOrderHeader.SubTotal column.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'TRIGGER', @level2name = N'uPurchaseOrderDetail'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'AFTER UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in PurchaseOrderDetail and updates the PurchaseOrderHeader.SubTotal column.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderDetail', @level2type = N'TRIGGER', @level2name = N'uPurchaseOrderDetail'
END
GO
----------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; 
----------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'General purchase order information. See PurchaseOrderDetail.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'General purchase order information. See PurchaseOrderDetail.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = default, @level2name = default
END
GO
-----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = PurchaseOrderID;
-----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'PurchaseOrderID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'PurchaseOrderID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'PurchaseOrderID'
END
GO
----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = RevisionNumber;
----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'RevisionNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Incremental number to track changes to the purchase order over time.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'RevisionNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Incremental number to track changes to the purchase order over time.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'RevisionNumber'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = Status;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'Status'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Order current status. 1 = Pending; 2 = Approved; 3 = Rejected; 4 = Complete', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'Status'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Order current status. 1 = Pending; 2 = Approved; 3 = Rejected; 4 = Complete', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'Status'
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = EmployeeID;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'EmployeeID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Employee who created the purchase order. Foreign key to Employee.EmployeeID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'EmployeeID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Employee who created the purchase order. Foreign key to Employee.EmployeeID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'EmployeeID'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = VendorID;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'VendorID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Vendor with whom the purchase order is placed. Foreign key to Vendor.VendorID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'VendorID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Vendor with whom the purchase order is placed. Foreign key to Vendor.VendorID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'VendorID'
END
GO
--------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = ShipMethodID;
--------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'ShipMethodID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Shipping method. Foreign key to ShipMethod.ShipMethodID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'ShipMethodID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Shipping method. Foreign key to ShipMethod.ShipMethodID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'ShipMethodID'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = OrderDate;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'OrderDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Purchase order creation date.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'OrderDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Purchase order creation date.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'OrderDate'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = ShipDate;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'ShipDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Estimated shipment date from the vendor.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'ShipDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Estimated shipment date from the vendor.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'ShipDate'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = SubTotal;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'SubTotal'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Purchase order subtotal. Computed as SUM(PurchaseOrderDetail.LineTotal)for the appropriate PurchaseOrderID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'SubTotal'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Purchase order subtotal. Computed as SUM(PurchaseOrderDetail.LineTotal)for the appropriate PurchaseOrderID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'SubTotal'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = TaxAmt;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'TaxAmt'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Tax amount.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'TaxAmt'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Tax amount.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'TaxAmt'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = Freight;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'Freight'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Shipping cost.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'Freight'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Shipping cost.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'Freight'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = TotalDue;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'TotalDue'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Total due to vendor. Computed as Subtotal + TaxAmt + Freight.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'TotalDue'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Total due to vendor. Computed as Subtotal + TaxAmt + Freight.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'TotalDue'
END
GO
--------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; COLUMN = ModifiedDate;
--------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
----------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; INDEX = IX_PurchaseOrderHeader_EmployeeID;
----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'INDEX', N'IX_PurchaseOrderHeader_EmployeeID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'INDEX', @level2name = N'IX_PurchaseOrderHeader_EmployeeID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'INDEX', @level2name = N'IX_PurchaseOrderHeader_EmployeeID'
END
GO
--------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; INDEX = IX_PurchaseOrderHeader_VendorID;
--------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'INDEX', N'IX_PurchaseOrderHeader_VendorID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'INDEX', @level2name = N'IX_PurchaseOrderHeader_VendorID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'INDEX', @level2name = N'IX_PurchaseOrderHeader_VendorID'
END
GO
--------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; CONSTRAINT = PK_PurchaseOrderHeader_PurchaseOrderID;
--------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'CONSTRAINT', N'PK_PurchaseOrderHeader_PurchaseOrderID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'CONSTRAINT', @level2name = N'PK_PurchaseOrderHeader_PurchaseOrderID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'CONSTRAINT', @level2name = N'PK_PurchaseOrderHeader_PurchaseOrderID'
END
GO
-----------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = PurchaseOrderHeader; TRIGGER = uPurchaseOrderHeader;
-----------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'PurchaseOrderHeader', N'TRIGGER', N'uPurchaseOrderHeader'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the PurchaseOrderHeader table.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'TRIGGER', @level2name = N'uPurchaseOrderHeader'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the PurchaseOrderHeader table.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'PurchaseOrderHeader', @level2type = N'TRIGGER', @level2name = N'uPurchaseOrderHeader'
END
GO
-------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ShipMethod; 
-------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ShipMethod', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Shipping company lookup table.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Shipping company lookup table.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = default, @level2name = default
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ShipMethod; COLUMN = ShipMethodID;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ShipMethod', N'COLUMN', N'ShipMethodID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for ShipMethod records.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'ShipMethodID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for ShipMethod records.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'ShipMethodID'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ShipMethod; COLUMN = Name;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ShipMethod', N'COLUMN', N'Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Shipping company name.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Shipping company name.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'Name'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ShipMethod; COLUMN = ShipBase;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ShipMethod', N'COLUMN', N'ShipBase'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Minimum shipping charge.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'ShipBase'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Minimum shipping charge.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'ShipBase'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ShipMethod; COLUMN = ShipRate;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ShipMethod', N'COLUMN', N'ShipRate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Shipping charge per pound.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'ShipRate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Shipping charge per pound.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'ShipRate'
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ShipMethod; COLUMN = rowguid;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ShipMethod', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ShipMethod; COLUMN = ModifiedDate;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ShipMethod', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ShipMethod; INDEX = AK_ShipMethod_Name;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ShipMethod', N'INDEX', N'AK_ShipMethod_Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'INDEX', @level2name = N'AK_ShipMethod_Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'INDEX', @level2name = N'AK_ShipMethod_Name'
END
GO
-------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ShipMethod; INDEX = AK_ShipMethod_rowguid;
-------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ShipMethod', N'INDEX', N'AK_ShipMethod_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'INDEX', @level2name = N'AK_ShipMethod_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'INDEX', @level2name = N'AK_ShipMethod_rowguid'
END
GO
-----------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = ShipMethod; CONSTRAINT = PK_ShipMethod_ShipMethodID;
-----------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'ShipMethod', N'CONSTRAINT', N'PK_ShipMethod_ShipMethodID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'CONSTRAINT', @level2name = N'PK_ShipMethod_ShipMethodID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'ShipMethod', @level2type = N'CONSTRAINT', @level2name = N'PK_ShipMethod_ShipMethodID'
END
GO
---------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; 
---------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Companies from whom Adventure Works Cycles purchases parts or other goods.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Companies from whom Adventure Works Cycles purchases parts or other goods.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; COLUMN = VendorID;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', N'COLUMN', N'VendorID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for Vendor records.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'VendorID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for Vendor records.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'VendorID'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; COLUMN = AccountNumber;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', N'COLUMN', N'AccountNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Vendor account (identification) number.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'AccountNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Vendor account (identification) number.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'AccountNumber'
END
GO
-----------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; COLUMN = Name;
-----------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', N'COLUMN', N'Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Company name.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Company name.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'Name'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; COLUMN = CreditRating;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', N'COLUMN', N'CreditRating'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'CreditRating'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'CreditRating'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; COLUMN = PreferredVendorStatus;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', N'COLUMN', N'PreferredVendorStatus'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'0 = Do not use if another vendor is available. 1 = Preferred over other vendors supplying the same product.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'PreferredVendorStatus'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'0 = Do not use if another vendor is available. 1 = Preferred over other vendors supplying the same product.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'PreferredVendorStatus'
END
GO
-----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; COLUMN = ActiveFlag;
-----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', N'COLUMN', N'ActiveFlag'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'0 = Vendor no longer used. 1 = Vendor is actively used.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'ActiveFlag'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'0 = Vendor no longer used. 1 = Vendor is actively used.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'ActiveFlag'
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; COLUMN = PurchasingWebServiceURL;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', N'COLUMN', N'PurchasingWebServiceURL'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Vendor URL.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'PurchasingWebServiceURL'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Vendor URL.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'PurchasingWebServiceURL'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; COLUMN = ModifiedDate;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; INDEX = AK_Vendor_AccountNumber;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', N'INDEX', N'AK_Vendor_AccountNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'INDEX', @level2name = N'AK_Vendor_AccountNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'INDEX', @level2name = N'AK_Vendor_AccountNumber'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; CONSTRAINT = PK_Vendor_VendorID;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', N'CONSTRAINT', N'PK_Vendor_VendorID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'CONSTRAINT', @level2name = N'PK_Vendor_VendorID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'CONSTRAINT', @level2name = N'PK_Vendor_VendorID'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = Vendor; TRIGGER = dVendor;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'Vendor', N'TRIGGER', N'dVendor'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'INSTEAD OF DELETE trigger which keeps Vendors from being deleted.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'TRIGGER', @level2name = N'dVendor'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'INSTEAD OF DELETE trigger which keeps Vendors from being deleted.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'Vendor', @level2type = N'TRIGGER', @level2name = N'dVendor'
END
GO
----------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorAddress; 
----------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorAddress', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Cross-reference mapping vendors and addresses.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Cross-reference mapping vendors and addresses.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorAddress; COLUMN = VendorID;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorAddress', N'COLUMN', N'VendorID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Vendor.VendorID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'COLUMN', @level2name = N'VendorID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Vendor.VendorID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'COLUMN', @level2name = N'VendorID'
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorAddress; COLUMN = AddressID;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorAddress', N'COLUMN', N'AddressID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Address.AddressID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'COLUMN', @level2name = N'AddressID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Address.AddressID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'COLUMN', @level2name = N'AddressID'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorAddress; COLUMN = AddressTypeID;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorAddress', N'COLUMN', N'AddressTypeID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Address type. Foreign key to AddressType.AddressTypeID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'COLUMN', @level2name = N'AddressTypeID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Address type. Foreign key to AddressType.AddressTypeID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'COLUMN', @level2name = N'AddressTypeID'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorAddress; COLUMN = ModifiedDate;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorAddress', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
---------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorAddress; INDEX = IX_VendorAddress_AddressID;
---------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorAddress', N'INDEX', N'IX_VendorAddress_AddressID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'INDEX', @level2name = N'IX_VendorAddress_AddressID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'INDEX', @level2name = N'IX_VendorAddress_AddressID'
END
GO
-----------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorAddress; CONSTRAINT = PK_VendorAddress_VendorID_AddressID;
-----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorAddress', N'CONSTRAINT', N'PK_VendorAddress_VendorID_AddressID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'CONSTRAINT', @level2name = N'PK_VendorAddress_VendorID_AddressID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorAddress', @level2type = N'CONSTRAINT', @level2name = N'PK_VendorAddress_VendorID_AddressID'
END
GO
----------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorContact; 
----------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorContact', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping vendors and their employees.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping vendors and their employees.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorContact; COLUMN = VendorID;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorContact', N'COLUMN', N'VendorID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'COLUMN', @level2name = N'VendorID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'COLUMN', @level2name = N'VendorID'
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorContact; COLUMN = ContactID;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorContact', N'COLUMN', N'ContactID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Contact (Vendor employee) identification number. Foreign key to Contact.ContactID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'COLUMN', @level2name = N'ContactID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Contact (Vendor employee) identification number. Foreign key to Contact.ContactID.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'COLUMN', @level2name = N'ContactID'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorContact; COLUMN = ContactTypeID;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorContact', N'COLUMN', N'ContactTypeID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Contact type such as sales manager, or sales agent.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'COLUMN', @level2name = N'ContactTypeID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Contact type such as sales manager, or sales agent.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'COLUMN', @level2name = N'ContactTypeID'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorContact; COLUMN = ModifiedDate;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorContact', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
---------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorContact; INDEX = IX_VendorContact_ContactID;
---------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorContact', N'INDEX', N'IX_VendorContact_ContactID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'INDEX', @level2name = N'IX_VendorContact_ContactID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'INDEX', @level2name = N'IX_VendorContact_ContactID'
END
GO
-------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorContact; INDEX = IX_VendorContact_ContactTypeID;
-------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorContact', N'INDEX', N'IX_VendorContact_ContactTypeID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'INDEX', @level2name = N'IX_VendorContact_ContactTypeID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'INDEX', @level2name = N'IX_VendorContact_ContactTypeID'
END
GO
-----------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Purchasing; TABLE = VendorContact; CONSTRAINT = PK_VendorContact_VendorID_ContactID;
-----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'TABLE', N'VendorContact', N'CONSTRAINT', N'PK_VendorContact_VendorID_ContactID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'CONSTRAINT', @level2name = N'PK_VendorContact_VendorID_ContactID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'TABLE', @level1name = N'VendorContact', @level2type = N'CONSTRAINT', @level2name = N'PK_VendorContact_VendorID_ContactID'
END
GO
---------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = ContactCreditCard; 
---------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ContactCreditCard', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping customers in the Contact table to their credit card information in the CreditCard table. ', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ContactCreditCard', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping customers in the Contact table to their credit card information in the CreditCard table. ', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ContactCreditCard', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = ContactCreditCard; COLUMN = ContactID;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ContactCreditCard', N'COLUMN', N'ContactID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Customer identification number. Foreign key to Contact.ContactID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ContactCreditCard', @level2type = N'COLUMN', @level2name = N'ContactID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Customer identification number. Foreign key to Contact.ContactID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ContactCreditCard', @level2type = N'COLUMN', @level2name = N'ContactID'
END
GO
-------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = ContactCreditCard; COLUMN = CreditCardID;
-------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ContactCreditCard', N'COLUMN', N'CreditCardID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Credit card identification number. Foreign key to CreditCard.CreditCardID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ContactCreditCard', @level2type = N'COLUMN', @level2name = N'CreditCardID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Credit card identification number. Foreign key to CreditCard.CreditCardID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ContactCreditCard', @level2type = N'COLUMN', @level2name = N'CreditCardID'
END
GO
-------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = ContactCreditCard; COLUMN = ModifiedDate;
-------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ContactCreditCard', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ContactCreditCard', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ContactCreditCard', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = ContactCreditCard; CONSTRAINT = PK_ContactCreditCard_ContactID_CreditCardID;
------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ContactCreditCard', N'CONSTRAINT', N'PK_ContactCreditCard_ContactID_CreditCardID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ContactCreditCard', @level2type = N'CONSTRAINT', @level2name = N'PK_ContactCreditCard_ContactID_CreditCardID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ContactCreditCard', @level2type = N'CONSTRAINT', @level2name = N'PK_ContactCreditCard_ContactID_CreditCardID'
END
GO
-------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CountryRegionCurrency; 
-------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CountryRegionCurrency', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping ISO currency codes to a country or region.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping ISO currency codes to a country or region.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CountryRegionCurrency; COLUMN = CountryRegionCode;
----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CountryRegionCurrency', N'COLUMN', N'CountryRegionCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ISO code for countries and regions. Foreign key to CountryRegion.CountryRegionCode.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = N'COLUMN', @level2name = N'CountryRegionCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ISO code for countries and regions. Foreign key to CountryRegion.CountryRegionCode.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = N'COLUMN', @level2name = N'CountryRegionCode'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CountryRegionCurrency; COLUMN = CurrencyCode;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CountryRegionCurrency', N'COLUMN', N'CurrencyCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ISO standard currency code. Foreign key to Currency.CurrencyCode.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = N'COLUMN', @level2name = N'CurrencyCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ISO standard currency code. Foreign key to Currency.CurrencyCode.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = N'COLUMN', @level2name = N'CurrencyCode'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CountryRegionCurrency; COLUMN = ModifiedDate;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CountryRegionCurrency', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
-----------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CountryRegionCurrency; INDEX = IX_CountryRegionCurrency_CurrencyCode;
-----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CountryRegionCurrency', N'INDEX', N'IX_CountryRegionCurrency_CurrencyCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = N'INDEX', @level2name = N'IX_CountryRegionCurrency_CurrencyCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = N'INDEX', @level2name = N'IX_CountryRegionCurrency_CurrencyCode'
END
GO
----------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CountryRegionCurrency; CONSTRAINT = PK_CountryRegionCurrency_CountryRegionCode_CurrencyCode;
----------------------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CountryRegionCurrency', N'CONSTRAINT', N'PK_CountryRegionCurrency_CountryRegionCode_CurrencyCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = N'CONSTRAINT', @level2name = N'PK_CountryRegionCurrency_CountryRegionCode_CurrencyCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CountryRegionCurrency', @level2type = N'CONSTRAINT', @level2name = N'PK_CountryRegionCurrency_CountryRegionCode_CurrencyCode'
END
GO
--------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CreditCard; 
--------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CreditCard', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Customer credit card information.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Customer credit card information.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = default, @level2name = default
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CreditCard; COLUMN = CreditCardID;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CreditCard', N'COLUMN', N'CreditCardID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for CreditCard records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'CreditCardID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for CreditCard records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'CreditCardID'
END
GO
--------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CreditCard; COLUMN = CardType;
--------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CreditCard', N'COLUMN', N'CardType'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Credit card name.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'CardType'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Credit card name.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'CardType'
END
GO
----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CreditCard; COLUMN = CardNumber;
----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CreditCard', N'COLUMN', N'CardNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Credit card number.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'CardNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Credit card number.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'CardNumber'
END
GO
--------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CreditCard; COLUMN = ExpMonth;
--------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CreditCard', N'COLUMN', N'ExpMonth'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Credit card expiration month.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'ExpMonth'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Credit card expiration month.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'ExpMonth'
END
GO
-------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CreditCard; COLUMN = ExpYear;
-------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CreditCard', N'COLUMN', N'ExpYear'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Credit card expiration year.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'ExpYear'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Credit card expiration year.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'ExpYear'
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CreditCard; COLUMN = ModifiedDate;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CreditCard', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CreditCard; INDEX = AK_CreditCard_CardNumber;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CreditCard', N'INDEX', N'AK_CreditCard_CardNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'INDEX', @level2name = N'AK_CreditCard_CardNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'INDEX', @level2name = N'AK_CreditCard_CardNumber'
END
GO
------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CreditCard; CONSTRAINT = PK_CreditCard_CreditCardID;
------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CreditCard', N'CONSTRAINT', N'PK_CreditCard_CreditCardID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'CONSTRAINT', @level2name = N'PK_CreditCard_CreditCardID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CreditCard', @level2type = N'CONSTRAINT', @level2name = N'PK_CreditCard_CreditCardID'
END
GO
------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Currency; 
------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Currency', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Lookup table containing standard ISO currencies.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Lookup table containing standard ISO currencies.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Currency; COLUMN = CurrencyCode;
----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Currency', N'COLUMN', N'CurrencyCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'The ISO code for the Currency.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = N'COLUMN', @level2name = N'CurrencyCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'The ISO code for the Currency.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = N'COLUMN', @level2name = N'CurrencyCode'
END
GO
--------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Currency; COLUMN = Name;
--------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Currency', N'COLUMN', N'Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Currency name.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = N'COLUMN', @level2name = N'Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Currency name.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = N'COLUMN', @level2name = N'Name'
END
GO
----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Currency; COLUMN = ModifiedDate;
----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Currency', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Currency; INDEX = AK_Currency_Name;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Currency', N'INDEX', N'AK_Currency_Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = N'INDEX', @level2name = N'AK_Currency_Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = N'INDEX', @level2name = N'AK_Currency_Name'
END
GO
--------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Currency; CONSTRAINT = PK_Currency_CurrencyCode;
--------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Currency', N'CONSTRAINT', N'PK_Currency_CurrencyCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = N'CONSTRAINT', @level2name = N'PK_Currency_CurrencyCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Currency', @level2type = N'CONSTRAINT', @level2name = N'PK_Currency_CurrencyCode'
END
GO
----------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CurrencyRate; 
----------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CurrencyRate', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Currency exchange rates.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Currency exchange rates.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CurrencyRate; COLUMN = CurrencyRateID;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CurrencyRate', N'COLUMN', N'CurrencyRateID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for CurrencyRate records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'CurrencyRateID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for CurrencyRate records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'CurrencyRateID'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CurrencyRate; COLUMN = CurrencyRateDate;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CurrencyRate', N'COLUMN', N'CurrencyRateDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the exchange rate was obtained.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'CurrencyRateDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the exchange rate was obtained.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'CurrencyRateDate'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CurrencyRate; COLUMN = FromCurrencyCode;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CurrencyRate', N'COLUMN', N'FromCurrencyCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Exchange rate was converted from this currency code.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'FromCurrencyCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Exchange rate was converted from this currency code.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'FromCurrencyCode'
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CurrencyRate; COLUMN = ToCurrencyCode;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CurrencyRate', N'COLUMN', N'ToCurrencyCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Exchange rate was converted to this currency code.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'ToCurrencyCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Exchange rate was converted to this currency code.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'ToCurrencyCode'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CurrencyRate; COLUMN = AverageRate;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CurrencyRate', N'COLUMN', N'AverageRate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Average exchange rate for the day.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'AverageRate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Average exchange rate for the day.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'AverageRate'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CurrencyRate; COLUMN = EndOfDayRate;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CurrencyRate', N'COLUMN', N'EndOfDayRate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Final exchange rate for the day.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'EndOfDayRate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Final exchange rate for the day.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'EndOfDayRate'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CurrencyRate; COLUMN = ModifiedDate;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CurrencyRate', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
-----------------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CurrencyRate; INDEX = AK_CurrencyRate_CurrencyRateDate_FromCurrencyCode_ToCurrencyCode;
-----------------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CurrencyRate', N'INDEX', N'AK_CurrencyRate_CurrencyRateDate_FromCurrencyCode_ToCurrencyCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'INDEX', @level2name = N'AK_CurrencyRate_CurrencyRateDate_FromCurrencyCode_ToCurrencyCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'INDEX', @level2name = N'AK_CurrencyRate_CurrencyRateDate_FromCurrencyCode_ToCurrencyCode'
END
GO
------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CurrencyRate; CONSTRAINT = PK_CurrencyRate_CurrencyRateID;
------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CurrencyRate', N'CONSTRAINT', N'PK_CurrencyRate_CurrencyRateID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'CONSTRAINT', @level2name = N'PK_CurrencyRate_CurrencyRateID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CurrencyRate', @level2type = N'CONSTRAINT', @level2name = N'PK_CurrencyRate_CurrencyRateID'
END
GO
------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Customer; 
------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Customer', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Current customer information. Also see the Individual and Store tables.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Current customer information. Also see the Individual and Store tables.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = default, @level2name = default
END
GO
--------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Customer; COLUMN = CustomerID;
--------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Customer', N'COLUMN', N'CustomerID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for Customer records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for Customer records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Customer; COLUMN = TerritoryID;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Customer', N'COLUMN', N'TerritoryID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ID of the territory in which the customer is located. Foreign key to SalesTerritory.SalesTerritoryID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'TerritoryID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ID of the territory in which the customer is located. Foreign key to SalesTerritory.SalesTerritoryID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'TerritoryID'
END
GO
-----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Customer; COLUMN = AccountNumber;
-----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Customer', N'COLUMN', N'AccountNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique number identifying the customer assigned by the accounting system.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'AccountNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique number identifying the customer assigned by the accounting system.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'AccountNumber'
END
GO
----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Customer; COLUMN = CustomerType;
----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Customer', N'COLUMN', N'CustomerType'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Customer type: I = Individual, S = Store', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'CustomerType'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Customer type: I = Individual, S = Store', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'CustomerType'
END
GO
-----------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Customer; COLUMN = rowguid;
-----------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Customer', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Customer; COLUMN = ModifiedDate;
----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Customer', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Customer; INDEX = AK_Customer_AccountNumber;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Customer', N'INDEX', N'AK_Customer_AccountNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'INDEX', @level2name = N'AK_Customer_AccountNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'INDEX', @level2name = N'AK_Customer_AccountNumber'
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Customer; INDEX = AK_Customer_rowguid;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Customer', N'INDEX', N'AK_Customer_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'INDEX', @level2name = N'AK_Customer_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'INDEX', @level2name = N'AK_Customer_rowguid'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Customer; INDEX = IX_Customer_TerritoryID;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Customer', N'INDEX', N'IX_Customer_TerritoryID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'INDEX', @level2name = N'IX_Customer_TerritoryID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'INDEX', @level2name = N'IX_Customer_TerritoryID'
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Customer; CONSTRAINT = PK_Customer_CustomerID;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Customer', N'CONSTRAINT', N'PK_Customer_CustomerID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'CONSTRAINT', @level2name = N'PK_Customer_CustomerID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Customer', @level2type = N'CONSTRAINT', @level2name = N'PK_Customer_CustomerID'
END
GO
-------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CustomerAddress; 
-------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CustomerAddress', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping customers to their address(es).', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping customers to their address(es).', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CustomerAddress; COLUMN = CustomerID;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CustomerAddress', N'COLUMN', N'CustomerID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Customer.CustomerID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Customer.CustomerID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CustomerAddress; COLUMN = AddressID;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CustomerAddress', N'COLUMN', N'AddressID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Address.AddressID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'COLUMN', @level2name = N'AddressID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Address.AddressID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'COLUMN', @level2name = N'AddressID'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CustomerAddress; COLUMN = AddressTypeID;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CustomerAddress', N'COLUMN', N'AddressTypeID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Address type. Foreign key to AddressType.AddressTypeID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'COLUMN', @level2name = N'AddressTypeID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Address type. Foreign key to AddressType.AddressTypeID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'COLUMN', @level2name = N'AddressTypeID'
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CustomerAddress; COLUMN = rowguid;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CustomerAddress', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CustomerAddress; COLUMN = ModifiedDate;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CustomerAddress', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CustomerAddress; INDEX = AK_CustomerAddress_rowguid;
------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CustomerAddress', N'INDEX', N'AK_CustomerAddress_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'INDEX', @level2name = N'AK_CustomerAddress_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'INDEX', @level2name = N'AK_CustomerAddress_rowguid'
END
GO
------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = CustomerAddress; CONSTRAINT = PK_CustomerAddress_CustomerID_AddressID;
------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'CustomerAddress', N'CONSTRAINT', N'PK_CustomerAddress_CustomerID_AddressID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'CONSTRAINT', @level2name = N'PK_CustomerAddress_CustomerID_AddressID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'CustomerAddress', @level2type = N'CONSTRAINT', @level2name = N'PK_CustomerAddress_CustomerID_AddressID'
END
GO
--------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Individual; 
--------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Individual', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Demographic data about customers that purchase Adventure Works products online.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Demographic data about customers that purchase Adventure Works products online.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Individual; COLUMN = CustomerID;
----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Individual', N'COLUMN', N'CustomerID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique customer identification number. Foreign key to Customer.CustomerID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique customer identification number. Foreign key to Customer.CustomerID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Individual; COLUMN = ContactID;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Individual', N'COLUMN', N'ContactID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Identifies the customer in the Contact table. Foreign key to Contact.ContactID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'COLUMN', @level2name = N'ContactID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Identifies the customer in the Contact table. Foreign key to Contact.ContactID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'COLUMN', @level2name = N'ContactID'
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Individual; COLUMN = Demographics;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Individual', N'COLUMN', N'Demographics'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Personal information such as hobbies, and income collected from online shoppers. Used for sales analysis.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'COLUMN', @level2name = N'Demographics'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Personal information such as hobbies, and income collected from online shoppers. Used for sales analysis.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'COLUMN', @level2name = N'Demographics'
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Individual; COLUMN = ModifiedDate;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Individual', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Individual; CONSTRAINT = PK_Individual_CustomerID;
----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Individual', N'CONSTRAINT', N'PK_Individual_CustomerID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'CONSTRAINT', @level2name = N'PK_Individual_CustomerID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'CONSTRAINT', @level2name = N'PK_Individual_CustomerID'
END
GO
---------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Individual; INDEX = PXML_Individual_Demographics;
---------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Individual', N'INDEX', N'PXML_Individual_Demographics'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary XML index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'INDEX', @level2name = N'PXML_Individual_Demographics'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary XML index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'INDEX', @level2name = N'PXML_Individual_Demographics'
END
GO
------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Individual; INDEX = XMLPATH_Individual_Demographics;
------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Individual', N'INDEX', N'XMLPATH_Individual_Demographics'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Secondary XML index for path.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'INDEX', @level2name = N'XMLPATH_Individual_Demographics'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Secondary XML index for path.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'INDEX', @level2name = N'XMLPATH_Individual_Demographics'
END
GO
----------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Individual; INDEX = XMLPROPERTY_Individual_Demographics;
----------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Individual', N'INDEX', N'XMLPROPERTY_Individual_Demographics'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Secondary XML index for property.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'INDEX', @level2name = N'XMLPROPERTY_Individual_Demographics'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Secondary XML index for property.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'INDEX', @level2name = N'XMLPROPERTY_Individual_Demographics'
END
GO
-------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Individual; INDEX = XMLVALUE_Individual_Demographics;
-------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Individual', N'INDEX', N'XMLVALUE_Individual_Demographics'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Secondary XML index for value.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'INDEX', @level2name = N'XMLVALUE_Individual_Demographics'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Secondary XML index for value.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'INDEX', @level2name = N'XMLVALUE_Individual_Demographics'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = Individual; TRIGGER = iuIndividual;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Individual', N'TRIGGER', N'iuIndividual'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'AFTER INSERT, UPDATE trigger inserting Individual only if the Customer does not exist in the Store table and setting the ModifiedDate column in the Individual table to the current date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'TRIGGER', @level2name = N'iuIndividual'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'AFTER INSERT, UPDATE trigger inserting Individual only if the Customer does not exist in the Store table and setting the ModifiedDate column in the Individual table to the current date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Individual', @level2type = N'TRIGGER', @level2name = N'iuIndividual'
END
GO
--------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; 
--------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Individual products associated with a specific sales order. See SalesOrderHeader.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Individual products associated with a specific sales order. See SalesOrderHeader.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = default, @level2name = default
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; COLUMN = SalesOrderID;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'COLUMN', N'SalesOrderID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to SalesOrderHeader.SalesOrderID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'SalesOrderID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to SalesOrderHeader.SalesOrderID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'SalesOrderID'
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; COLUMN = SalesOrderDetailID;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'COLUMN', N'SalesOrderDetailID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. One incremental unique number per product sold.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'SalesOrderDetailID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. One incremental unique number per product sold.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'SalesOrderDetailID'
END
GO
---------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; COLUMN = CarrierTrackingNumber;
---------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'COLUMN', N'CarrierTrackingNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Shipment tracking number supplied by the shipper.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'CarrierTrackingNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Shipment tracking number supplied by the shipper.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'CarrierTrackingNumber'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; COLUMN = OrderQty;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'COLUMN', N'OrderQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Quantity ordered per product.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'OrderQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Quantity ordered per product.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'OrderQty'
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; COLUMN = ProductID;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'COLUMN', N'ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Product sold to customer. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Product sold to customer. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'ProductID'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; COLUMN = SpecialOfferID;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'COLUMN', N'SpecialOfferID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Promotional code. Foreign key to SpecialOffer.SpecialOfferID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'SpecialOfferID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Promotional code. Foreign key to SpecialOffer.SpecialOfferID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'SpecialOfferID'
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; COLUMN = UnitPrice;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'COLUMN', N'UnitPrice'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Selling price of a single product.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'UnitPrice'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Selling price of a single product.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'UnitPrice'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; COLUMN = UnitPriceDiscount;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'COLUMN', N'UnitPriceDiscount'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Discount amount.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'UnitPriceDiscount'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Discount amount.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'UnitPriceDiscount'
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; COLUMN = LineTotal;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'COLUMN', N'LineTotal'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Per product subtotal. Computed as UnitPrice * (1 - UnitPriceDiscount) * OrderQty.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'LineTotal'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Per product subtotal. Computed as UnitPrice * (1 - UnitPriceDiscount) * OrderQty.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'LineTotal'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; COLUMN = rowguid;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; COLUMN = ModifiedDate;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
--------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; INDEX = AK_SalesOrderDetail_rowguid;
--------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'INDEX', N'AK_SalesOrderDetail_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'INDEX', @level2name = N'AK_SalesOrderDetail_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'INDEX', @level2name = N'AK_SalesOrderDetail_rowguid'
END
GO
----------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; INDEX = IX_SalesOrderDetail_ProductID;
----------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'INDEX', N'IX_SalesOrderDetail_ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'INDEX', @level2name = N'IX_SalesOrderDetail_ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'INDEX', @level2name = N'IX_SalesOrderDetail_ProductID'
END
GO
-------------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; CONSTRAINT = PK_SalesOrderDetail_SalesOrderID_SalesOrderDetailID;
-------------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'CONSTRAINT', N'PK_SalesOrderDetail_SalesOrderID_SalesOrderDetailID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesOrderDetail_SalesOrderID_SalesOrderDetailID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesOrderDetail_SalesOrderID_SalesOrderDetailID'
END
GO
--------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderDetail; TRIGGER = iduSalesOrderDetail;
--------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderDetail', N'TRIGGER', N'iduSalesOrderDetail'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'AFTER INSERT, DELETE, UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in SalesOrderDetail and updates the SalesOrderHeader.SubTotal column.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'TRIGGER', @level2name = N'iduSalesOrderDetail'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'AFTER INSERT, DELETE, UPDATE trigger that inserts a row in the TransactionHistory table, updates ModifiedDate in SalesOrderDetail and updates the SalesOrderHeader.SubTotal column.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderDetail', @level2type = N'TRIGGER', @level2name = N'iduSalesOrderDetail'
END
GO
--------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; 
--------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'General sales order information.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'General sales order information.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = default, @level2name = default
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = SalesOrderID;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'SalesOrderID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'SalesOrderID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'SalesOrderID'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = RevisionNumber;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'RevisionNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Incremental number to track changes to the sales order over time.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'RevisionNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Incremental number to track changes to the sales order over time.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'RevisionNumber'
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = OrderDate;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'OrderDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Dates the sales order was created.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'OrderDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Dates the sales order was created.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'OrderDate'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = DueDate;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'DueDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date the order is due to the customer.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'DueDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date the order is due to the customer.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'DueDate'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = ShipDate;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'ShipDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date the order was shipped to the customer.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'ShipDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date the order was shipped to the customer.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'ShipDate'
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = Status;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'Status'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'Status'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Order current status. 1 = In process; 2 = Approved; 3 = Backordered; 4 = Rejected; 5 = Shipped; 6 = Cancelled', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'Status'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = OnlineOrderFlag;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'OnlineOrderFlag'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'0 = Order placed by sales person. 1 = Order placed online by customer.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'OnlineOrderFlag'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'0 = Order placed by sales person. 1 = Order placed online by customer.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'OnlineOrderFlag'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = SalesOrderNumber;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'SalesOrderNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique sales order identification number.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'SalesOrderNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique sales order identification number.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'SalesOrderNumber'
END
GO
-------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = PurchaseOrderNumber;
-------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'PurchaseOrderNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Customer purchase order number reference. ', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'PurchaseOrderNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Customer purchase order number reference. ', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'PurchaseOrderNumber'
END
GO
-------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = AccountNumber;
-------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'AccountNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Financial accounting number reference.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'AccountNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Financial accounting number reference.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'AccountNumber'
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = CustomerID;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'CustomerID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Customer identification number. Foreign key to Customer.CustomerID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Customer identification number. Foreign key to Customer.CustomerID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = ContactID;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'ContactID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Customer contact identification number. Foreign key to Contact.ContactID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'ContactID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Customer contact identification number. Foreign key to Contact.ContactID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'ContactID'
END
GO
-------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = SalesPersonID;
-------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'SalesPersonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales person who created the sales order. Foreign key to SalesPerson.SalePersonID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'SalesPersonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales person who created the sales order. Foreign key to SalesPerson.SalePersonID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'SalesPersonID'
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = TerritoryID;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'TerritoryID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Territory in which the sale was made. Foreign key to SalesTerritory.SalesTerritoryID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'TerritoryID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Territory in which the sale was made. Foreign key to SalesTerritory.SalesTerritoryID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'TerritoryID'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = BillToAddressID;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'BillToAddressID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Customer billing address. Foreign key to Address.AddressID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'BillToAddressID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Customer billing address. Foreign key to Address.AddressID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'BillToAddressID'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = ShipToAddressID;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'ShipToAddressID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Customer shipping address. Foreign key to Address.AddressID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'ShipToAddressID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Customer shipping address. Foreign key to Address.AddressID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'ShipToAddressID'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = ShipMethodID;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'ShipMethodID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Shipping method. Foreign key to ShipMethod.ShipMethodID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'ShipMethodID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Shipping method. Foreign key to ShipMethod.ShipMethodID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'ShipMethodID'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = CreditCardID;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'CreditCardID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Credit card identification number. Foreign key to CreditCard.CreditCardID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'CreditCardID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Credit card identification number. Foreign key to CreditCard.CreditCardID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'CreditCardID'
END
GO
----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = CreditCardApprovalCode;
----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'CreditCardApprovalCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Approval code provided by the credit card company.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'CreditCardApprovalCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Approval code provided by the credit card company.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'CreditCardApprovalCode'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = CurrencyRateID;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'CurrencyRateID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Currency exchange rate used. Foreign key to CurrencyRate.CurrencyRateID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'CurrencyRateID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Currency exchange rate used. Foreign key to CurrencyRate.CurrencyRateID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'CurrencyRateID'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = SubTotal;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'SubTotal'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'SubTotal'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales subtotal. Computed as SUM(SalesOrderDetail.LineTotal)for the appropriate SalesOrderID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'SubTotal'
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = TaxAmt;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'TaxAmt'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Tax amount.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'TaxAmt'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Tax amount.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'TaxAmt'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = Freight;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'Freight'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Shipping cost.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'Freight'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Shipping cost.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'Freight'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = TotalDue;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'TotalDue'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Total due from customer. Computed as Subtotal + TaxAmt + Freight.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'TotalDue'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Total due from customer. Computed as Subtotal + TaxAmt + Freight.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'TotalDue'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = Comment;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'Comment'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales representative comments.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'Comment'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales representative comments.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'Comment'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = rowguid;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; COLUMN = ModifiedDate;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
--------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; INDEX = AK_SalesOrderHeader_rowguid;
--------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'INDEX', N'AK_SalesOrderHeader_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'INDEX', @level2name = N'AK_SalesOrderHeader_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'INDEX', @level2name = N'AK_SalesOrderHeader_rowguid'
END
GO
-----------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; INDEX = AK_SalesOrderHeader_SalesOrderNumber;
-----------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'INDEX', N'AK_SalesOrderHeader_SalesOrderNumber'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'INDEX', @level2name = N'AK_SalesOrderHeader_SalesOrderNumber'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'INDEX', @level2name = N'AK_SalesOrderHeader_SalesOrderNumber'
END
GO
-----------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; INDEX = IX_SalesOrderHeader_CustomerID;
-----------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'INDEX', N'IX_SalesOrderHeader_CustomerID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'INDEX', @level2name = N'IX_SalesOrderHeader_CustomerID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'INDEX', @level2name = N'IX_SalesOrderHeader_CustomerID'
END
GO
--------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; INDEX = IX_SalesOrderHeader_SalesPersonID;
--------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'INDEX', N'IX_SalesOrderHeader_SalesPersonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'INDEX', @level2name = N'IX_SalesOrderHeader_SalesPersonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'INDEX', @level2name = N'IX_SalesOrderHeader_SalesPersonID'
END
GO
------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:39 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; CONSTRAINT = PK_SalesOrderHeader_SalesOrderID;
------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'CONSTRAINT', N'PK_SalesOrderHeader_SalesOrderID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesOrderHeader_SalesOrderID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesOrderHeader_SalesOrderID'
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeader; TRIGGER = uSalesOrderHeader;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeader', N'TRIGGER', N'uSalesOrderHeader'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'TRIGGER', @level2name = N'uSalesOrderHeader'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'AFTER UPDATE trigger that updates the RevisionNumber and ModifiedDate columns in the SalesOrderHeader table.Updates the SalesYTD column in the SalesPerson and SalesTerritory tables.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeader', @level2type = N'TRIGGER', @level2name = N'uSalesOrderHeader'
END
GO
-------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeaderSalesReason; 
-------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeaderSalesReason', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping sales orders to sales reason codes.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeaderSalesReason', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping sales orders to sales reason codes.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeaderSalesReason', @level2type = default, @level2name = default
END
GO
-----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeaderSalesReason; COLUMN = SalesOrderID;
-----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeaderSalesReason', N'COLUMN', N'SalesOrderID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to SalesOrderHeader.SalesOrderID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeaderSalesReason', @level2type = N'COLUMN', @level2name = N'SalesOrderID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to SalesOrderHeader.SalesOrderID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeaderSalesReason', @level2type = N'COLUMN', @level2name = N'SalesOrderID'
END
GO
------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeaderSalesReason; COLUMN = SalesReasonID;
------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeaderSalesReason', N'COLUMN', N'SalesReasonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to SalesReason.SalesReasonID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeaderSalesReason', @level2type = N'COLUMN', @level2name = N'SalesReasonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to SalesReason.SalesReasonID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeaderSalesReason', @level2type = N'COLUMN', @level2name = N'SalesReasonID'
END
GO
-----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeaderSalesReason; COLUMN = ModifiedDate;
-----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeaderSalesReason', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeaderSalesReason', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeaderSalesReason', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesOrderHeaderSalesReason; CONSTRAINT = PK_SalesOrderHeaderSalesReason_SalesOrderID_SalesReasonID;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesOrderHeaderSalesReason', N'CONSTRAINT', N'PK_SalesOrderHeaderSalesReason_SalesOrderID_SalesReasonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeaderSalesReason', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesOrderHeaderSalesReason_SalesOrderID_SalesReasonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesOrderHeaderSalesReason', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesOrderHeaderSalesReason_SalesOrderID_SalesReasonID'
END
GO
---------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; 
---------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales representative current information.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales representative current information.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = default, @level2name = default
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; COLUMN = SalesPersonID;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', N'COLUMN', N'SalesPersonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for SalesPerson records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'SalesPersonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for SalesPerson records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'SalesPersonID'
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; COLUMN = TerritoryID;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', N'COLUMN', N'TerritoryID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Territory currently assigned to. Foreign key to SalesTerritory.SalesTerritoryID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'TerritoryID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Territory currently assigned to. Foreign key to SalesTerritory.SalesTerritoryID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'TerritoryID'
END
GO
-----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; COLUMN = SalesQuota;
-----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', N'COLUMN', N'SalesQuota'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Projected yearly sales.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'SalesQuota'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Projected yearly sales.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'SalesQuota'
END
GO
------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; COLUMN = Bonus;
------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', N'COLUMN', N'Bonus'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Bonus due if quota is met.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'Bonus'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Bonus due if quota is met.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'Bonus'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; COLUMN = CommissionPct;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', N'COLUMN', N'CommissionPct'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Commision percent received per sale.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'CommissionPct'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Commision percent received per sale.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'CommissionPct'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; COLUMN = SalesYTD;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', N'COLUMN', N'SalesYTD'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales total year to date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'SalesYTD'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales total year to date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'SalesYTD'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; COLUMN = SalesLastYear;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', N'COLUMN', N'SalesLastYear'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales total of previous year.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'SalesLastYear'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales total of previous year.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'SalesLastYear'
END
GO
--------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; COLUMN = rowguid;
--------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; COLUMN = ModifiedDate;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; INDEX = AK_SalesPerson_rowguid;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', N'INDEX', N'AK_SalesPerson_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'INDEX', @level2name = N'AK_SalesPerson_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'INDEX', @level2name = N'AK_SalesPerson_rowguid'
END
GO
---------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPerson; CONSTRAINT = PK_SalesPerson_SalesPersonID;
---------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPerson', N'CONSTRAINT', N'PK_SalesPerson_SalesPersonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesPerson_SalesPersonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPerson', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesPerson_SalesPersonID'
END
GO
---------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPersonQuotaHistory; 
---------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPersonQuotaHistory', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales performance tracking.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales performance tracking.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = default, @level2name = default
END
GO
--------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPersonQuotaHistory; COLUMN = SalesPersonID;
--------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPersonQuotaHistory', N'COLUMN', N'SalesPersonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales person identification number. Foreign key to SalesPerson.SalesPersonID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'COLUMN', @level2name = N'SalesPersonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales person identification number. Foreign key to SalesPerson.SalesPersonID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'COLUMN', @level2name = N'SalesPersonID'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPersonQuotaHistory; COLUMN = QuotaDate;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPersonQuotaHistory', N'COLUMN', N'QuotaDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales quota date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'COLUMN', @level2name = N'QuotaDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales quota date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'COLUMN', @level2name = N'QuotaDate'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPersonQuotaHistory; COLUMN = SalesQuota;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPersonQuotaHistory', N'COLUMN', N'SalesQuota'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales quota amount.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'COLUMN', @level2name = N'SalesQuota'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales quota amount.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'COLUMN', @level2name = N'SalesQuota'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPersonQuotaHistory; COLUMN = rowguid;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPersonQuotaHistory', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
-------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPersonQuotaHistory; COLUMN = ModifiedDate;
-------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPersonQuotaHistory', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
----------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPersonQuotaHistory; INDEX = AK_SalesPersonQuotaHistory_rowguid;
----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPersonQuotaHistory', N'INDEX', N'AK_SalesPersonQuotaHistory_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'INDEX', @level2name = N'AK_SalesPersonQuotaHistory_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'INDEX', @level2name = N'AK_SalesPersonQuotaHistory_rowguid'
END
GO
-------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesPersonQuotaHistory; CONSTRAINT = PK_SalesPersonQuotaHistory_SalesPersonID_QuotaDate;
-------------------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesPersonQuotaHistory', N'CONSTRAINT', N'PK_SalesPersonQuotaHistory_SalesPersonID_QuotaDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesPersonQuotaHistory_SalesPersonID_QuotaDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesPersonQuotaHistory', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesPersonQuotaHistory_SalesPersonID_QuotaDate'
END
GO
---------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesReason; 
---------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesReason', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Lookup table of customer purchase reasons.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Lookup table of customer purchase reasons.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = default, @level2name = default
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesReason; COLUMN = SalesReasonID;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesReason', N'COLUMN', N'SalesReasonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for SalesReason records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = N'COLUMN', @level2name = N'SalesReasonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for SalesReason records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = N'COLUMN', @level2name = N'SalesReasonID'
END
GO
-----------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesReason; COLUMN = Name;
-----------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesReason', N'COLUMN', N'Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales reason description.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = N'COLUMN', @level2name = N'Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales reason description.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = N'COLUMN', @level2name = N'Name'
END
GO
-----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesReason; COLUMN = ReasonType;
-----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesReason', N'COLUMN', N'ReasonType'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Category the sales reason belongs to.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = N'COLUMN', @level2name = N'ReasonType'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Category the sales reason belongs to.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = N'COLUMN', @level2name = N'ReasonType'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesReason; COLUMN = ModifiedDate;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesReason', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
---------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesReason; CONSTRAINT = PK_SalesReason_SalesReasonID;
---------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesReason', N'CONSTRAINT', N'PK_SalesReason_SalesReasonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesReason_SalesReasonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesReason', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesReason_SalesReasonID'
END
GO
----------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTaxRate; 
----------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTaxRate', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Tax rate lookup table.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Tax rate lookup table.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTaxRate; COLUMN = SalesTaxRateID;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTaxRate', N'COLUMN', N'SalesTaxRateID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for SalesTaxRate records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'SalesTaxRateID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for SalesTaxRate records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'SalesTaxRateID'
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTaxRate; COLUMN = StateProvinceID;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTaxRate', N'COLUMN', N'StateProvinceID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'State, province, or country/region the sales tax applies to.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'StateProvinceID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'State, province, or country/region the sales tax applies to.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'StateProvinceID'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTaxRate; COLUMN = TaxType;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTaxRate', N'COLUMN', N'TaxType'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'1 = Tax applied to retail transactions, 2 = Tax applied to wholesale transactions, 3 = Tax applied to all sales (retail and wholesale) transactions.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'TaxType'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'1 = Tax applied to retail transactions, 2 = Tax applied to wholesale transactions, 3 = Tax applied to all sales (retail and wholesale) transactions.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'TaxType'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTaxRate; COLUMN = TaxRate;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTaxRate', N'COLUMN', N'TaxRate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Tax rate amount.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'TaxRate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Tax rate amount.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'TaxRate'
END
GO
------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTaxRate; COLUMN = Name;
------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTaxRate', N'COLUMN', N'Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Tax rate description.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Tax rate description.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'Name'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTaxRate; COLUMN = rowguid;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTaxRate', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTaxRate; COLUMN = ModifiedDate;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTaxRate', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTaxRate; INDEX = AK_SalesTaxRate_rowguid;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTaxRate', N'INDEX', N'AK_SalesTaxRate_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'INDEX', @level2name = N'AK_SalesTaxRate_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'INDEX', @level2name = N'AK_SalesTaxRate_rowguid'
END
GO
----------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTaxRate; INDEX = AK_SalesTaxRate_StateProvinceID_TaxType;
----------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTaxRate', N'INDEX', N'AK_SalesTaxRate_StateProvinceID_TaxType'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'INDEX', @level2name = N'AK_SalesTaxRate_StateProvinceID_TaxType'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'INDEX', @level2name = N'AK_SalesTaxRate_StateProvinceID_TaxType'
END
GO
------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTaxRate; CONSTRAINT = PK_SalesTaxRate_SalesTaxRateID;
------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTaxRate', N'CONSTRAINT', N'PK_SalesTaxRate_SalesTaxRateID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesTaxRate_SalesTaxRateID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTaxRate', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesTaxRate_SalesTaxRateID'
END
GO
------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; 
------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales territory lookup table.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales territory lookup table.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; COLUMN = TerritoryID;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'COLUMN', N'TerritoryID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for SalesTerritory records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'TerritoryID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for SalesTerritory records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'TerritoryID'
END
GO
--------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; COLUMN = Name;
--------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'COLUMN', N'Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales territory description', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales territory description', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'Name'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; COLUMN = CountryRegionCode;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'COLUMN', N'CountryRegionCode'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ISO standard country or region code. Foreign key to CountryRegion.CountryRegionCode. ', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'CountryRegionCode'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ISO standard country or region code. Foreign key to CountryRegion.CountryRegionCode. ', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'CountryRegionCode'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; COLUMN = Group;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'COLUMN', N'Group'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Geographic area to which the sales territory belong.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'Group'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Geographic area to which the sales territory belong.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'Group'
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; COLUMN = SalesYTD;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'COLUMN', N'SalesYTD'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales in the territory year to date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'SalesYTD'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales in the territory year to date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'SalesYTD'
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; COLUMN = SalesLastYear;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'COLUMN', N'SalesLastYear'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales in the territory the previous year.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'SalesLastYear'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales in the territory the previous year.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'SalesLastYear'
END
GO
-----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; COLUMN = CostYTD;
-----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'COLUMN', N'CostYTD'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Business costs in the territory year to date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'CostYTD'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Business costs in the territory year to date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'CostYTD'
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; COLUMN = CostLastYear;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'COLUMN', N'CostLastYear'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Business costs in the territory the previous year.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'CostLastYear'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Business costs in the territory the previous year.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'CostLastYear'
END
GO
-----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; COLUMN = rowguid;
-----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; COLUMN = ModifiedDate;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
-------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; INDEX = AK_SalesTerritory_Name;
-------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'INDEX', N'AK_SalesTerritory_Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'INDEX', @level2name = N'AK_SalesTerritory_Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'INDEX', @level2name = N'AK_SalesTerritory_Name'
END
GO
----------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; INDEX = AK_SalesTerritory_rowguid;
----------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'INDEX', N'AK_SalesTerritory_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'INDEX', @level2name = N'AK_SalesTerritory_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'INDEX', @level2name = N'AK_SalesTerritory_rowguid'
END
GO
-------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritory; CONSTRAINT = PK_SalesTerritory_TerritoryID;
-------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritory', N'CONSTRAINT', N'PK_SalesTerritory_TerritoryID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesTerritory_TerritoryID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritory', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesTerritory_TerritoryID'
END
GO
-------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritoryHistory; 
-------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritoryHistory', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales representative transfers to other sales territories.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales representative transfers to other sales territories.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = default, @level2name = default
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritoryHistory; COLUMN = SalesPersonID;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritoryHistory', N'COLUMN', N'SalesPersonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for SalesTerritoryHistory records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'SalesPersonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for SalesTerritoryHistory records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'SalesPersonID'
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritoryHistory; COLUMN = TerritoryID;
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritoryHistory', N'COLUMN', N'TerritoryID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Territory identification number. Foreign key to SalesTerritory.SalesTerritoryID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'TerritoryID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Territory identification number. Foreign key to SalesTerritory.SalesTerritoryID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'TerritoryID'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritoryHistory; COLUMN = StartDate;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritoryHistory', N'COLUMN', N'StartDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date the sales representive started work in the territory.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'StartDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date the sales representive started work in the territory.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'StartDate'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritoryHistory; COLUMN = EndDate;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritoryHistory', N'COLUMN', N'EndDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date the sales representative left work in the territory.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'EndDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date the sales representative left work in the territory.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'EndDate'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritoryHistory; COLUMN = rowguid;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritoryHistory', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritoryHistory; COLUMN = ModifiedDate;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritoryHistory', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritoryHistory; INDEX = AK_SalesTerritoryHistory_rowguid;
------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritoryHistory', N'INDEX', N'AK_SalesTerritoryHistory_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'INDEX', @level2name = N'AK_SalesTerritoryHistory_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'INDEX', @level2name = N'AK_SalesTerritoryHistory_rowguid'
END
GO
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SalesTerritoryHistory; CONSTRAINT = PK_SalesTerritoryHistory_SalesPersonID_StartDate_TerritoryID;
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SalesTerritoryHistory', N'CONSTRAINT', N'PK_SalesTerritoryHistory_SalesPersonID_StartDate_TerritoryID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesTerritoryHistory_SalesPersonID_StartDate_TerritoryID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SalesTerritoryHistory', @level2type = N'CONSTRAINT', @level2name = N'PK_SalesTerritoryHistory_SalesPersonID_StartDate_TerritoryID'
END
GO
--------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = ShoppingCartItem; 
--------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ShoppingCartItem', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Contains online customer orders until the order is submitted or cancelled.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Contains online customer orders until the order is submitted or cancelled.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = default, @level2name = default
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = ShoppingCartItem; COLUMN = ShoppingCartItemID;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ShoppingCartItem', N'COLUMN', N'ShoppingCartItemID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for ShoppingCartItem records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'ShoppingCartItemID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for ShoppingCartItem records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'ShoppingCartItemID'
END
GO
--------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = ShoppingCartItem; COLUMN = ShoppingCartID;
--------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ShoppingCartItem', N'COLUMN', N'ShoppingCartID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Shopping cart identification number.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'ShoppingCartID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Shopping cart identification number.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'ShoppingCartID'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = ShoppingCartItem; COLUMN = Quantity;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ShoppingCartItem', N'COLUMN', N'Quantity'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Product quantity ordered.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'Quantity'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Product quantity ordered.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'Quantity'
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = ShoppingCartItem; COLUMN = ProductID;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ShoppingCartItem', N'COLUMN', N'ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Product ordered. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Product ordered. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'ProductID'
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = ShoppingCartItem; COLUMN = DateCreated;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ShoppingCartItem', N'COLUMN', N'DateCreated'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date the time the record was created.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'DateCreated'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date the time the record was created.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'DateCreated'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = ShoppingCartItem; COLUMN = ModifiedDate;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ShoppingCartItem', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
-------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = ShoppingCartItem; INDEX = IX_ShoppingCartItem_ShoppingCartID_ProductID;
-------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ShoppingCartItem', N'INDEX', N'IX_ShoppingCartItem_ShoppingCartID_ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'INDEX', @level2name = N'IX_ShoppingCartItem_ShoppingCartID_ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'INDEX', @level2name = N'IX_ShoppingCartItem_ShoppingCartID_ProductID'
END
GO
------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = ShoppingCartItem; CONSTRAINT = PK_ShoppingCartItem_ShoppingCartItemID;
------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'ShoppingCartItem', N'CONSTRAINT', N'PK_ShoppingCartItem_ShoppingCartItemID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'CONSTRAINT', @level2name = N'PK_ShoppingCartItem_ShoppingCartItemID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'ShoppingCartItem', @level2type = N'CONSTRAINT', @level2name = N'PK_ShoppingCartItem_ShoppingCartItemID'
END
GO
----------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; 
----------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sale discounts lookup table.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sale discounts lookup table.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; COLUMN = SpecialOfferID;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'COLUMN', N'SpecialOfferID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for SpecialOffer records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'SpecialOfferID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for SpecialOffer records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'SpecialOfferID'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; COLUMN = Description;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'COLUMN', N'Description'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Discount description.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'Description'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Discount description.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'Description'
END
GO
-------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; COLUMN = DiscountPct;
-------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'COLUMN', N'DiscountPct'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Discount precentage.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'DiscountPct'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Discount precentage.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'DiscountPct'
END
GO
------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; COLUMN = Type;
------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'COLUMN', N'Type'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Discount type category.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'Type'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Discount type category.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'Type'
END
GO
----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; COLUMN = Category;
----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'COLUMN', N'Category'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Group the discount applies to such as Reseller or Customer.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'Category'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Group the discount applies to such as Reseller or Customer.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'Category'
END
GO
-----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; COLUMN = StartDate;
-----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'COLUMN', N'StartDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Discount start date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'StartDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Discount start date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'StartDate'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; COLUMN = EndDate;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'COLUMN', N'EndDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Discount end date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'EndDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Discount end date.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'EndDate'
END
GO
--------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; COLUMN = MinQty;
--------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'COLUMN', N'MinQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Minimum discount percent allowed.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'MinQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Minimum discount percent allowed.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'MinQty'
END
GO
--------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; COLUMN = MaxQty;
--------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'COLUMN', N'MaxQty'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Maximum discount percent allowed.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'MaxQty'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Maximum discount percent allowed.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'MaxQty'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; COLUMN = rowguid;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; COLUMN = ModifiedDate;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; INDEX = AK_SpecialOffer_rowguid;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'INDEX', N'AK_SpecialOffer_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'INDEX', @level2name = N'AK_SpecialOffer_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'INDEX', @level2name = N'AK_SpecialOffer_rowguid'
END
GO
------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOffer; CONSTRAINT = PK_SpecialOffer_SpecialOfferID;
------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOffer', N'CONSTRAINT', N'PK_SpecialOffer_SpecialOfferID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'CONSTRAINT', @level2name = N'PK_SpecialOffer_SpecialOfferID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOffer', @level2type = N'CONSTRAINT', @level2name = N'PK_SpecialOffer_SpecialOfferID'
END
GO
-----------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOfferProduct; 
-----------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOfferProduct', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping products to special offer discounts.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping products to special offer discounts.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = default, @level2name = default
END
GO
-----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOfferProduct; COLUMN = SpecialOfferID;
-----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOfferProduct', N'COLUMN', N'SpecialOfferID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key for SpecialOfferProduct records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'COLUMN', @level2name = N'SpecialOfferID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key for SpecialOfferProduct records.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'COLUMN', @level2name = N'SpecialOfferID'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOfferProduct; COLUMN = ProductID;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOfferProduct', N'COLUMN', N'ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Product identification number. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'COLUMN', @level2name = N'ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Product identification number. Foreign key to Product.ProductID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'COLUMN', @level2name = N'ProductID'
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOfferProduct; COLUMN = rowguid;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOfferProduct', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
---------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOfferProduct; COLUMN = ModifiedDate;
---------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOfferProduct', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
--------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOfferProduct; INDEX = AK_SpecialOfferProduct_rowguid;
--------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOfferProduct', N'INDEX', N'AK_SpecialOfferProduct_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'INDEX', @level2name = N'AK_SpecialOfferProduct_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'INDEX', @level2name = N'AK_SpecialOfferProduct_rowguid'
END
GO
----------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOfferProduct; INDEX = IX_SpecialOfferProduct_ProductID;
----------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOfferProduct', N'INDEX', N'IX_SpecialOfferProduct_ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'INDEX', @level2name = N'IX_SpecialOfferProduct_ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'INDEX', @level2name = N'IX_SpecialOfferProduct_ProductID'
END
GO
------------------------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = SpecialOfferProduct; CONSTRAINT = PK_SpecialOfferProduct_SpecialOfferID_ProductID;
------------------------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'SpecialOfferProduct', N'CONSTRAINT', N'PK_SpecialOfferProduct_SpecialOfferID_ProductID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'CONSTRAINT', @level2name = N'PK_SpecialOfferProduct_SpecialOfferID_ProductID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'SpecialOfferProduct', @level2type = N'CONSTRAINT', @level2name = N'PK_SpecialOfferProduct_SpecialOfferID_ProductID'
END
GO
---------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; 
---------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Customers (resellers) of Adventure Works products.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Customers (resellers) of Adventure Works products.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = default, @level2name = default
END
GO
-----------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; COLUMN = CustomerID;
-----------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', N'COLUMN', N'CustomerID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Customer.CustomerID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key. Foreign key to Customer.CustomerID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
GO
-----------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; COLUMN = Name;
-----------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', N'COLUMN', N'Name'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Name of the store.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'Name'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Name of the store.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'Name'
END
GO
--------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; COLUMN = SalesPersonID;
--------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', N'COLUMN', N'SalesPersonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'SalesPersonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'SalesPersonID'
END
GO
-------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; COLUMN = Demographics;
-------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', N'COLUMN', N'Demographics'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Demographic informationg about the store such as the number of employees, annual sales and store type.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'Demographics'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Demographic informationg about the store such as the number of employees, annual sales and store type.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'Demographics'
END
GO
--------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; COLUMN = rowguid;
--------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
-------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; COLUMN = ModifiedDate;
-------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; INDEX = AK_Store_rowguid;
----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', N'INDEX', N'AK_Store_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'INDEX', @level2name = N'AK_Store_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'INDEX', @level2name = N'AK_Store_rowguid'
END
GO
----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; INDEX = IX_Store_SalesPersonID;
----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', N'INDEX', N'IX_Store_SalesPersonID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'INDEX', @level2name = N'IX_Store_SalesPersonID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'INDEX', @level2name = N'IX_Store_SalesPersonID'
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; CONSTRAINT = PK_Store_CustomerID;
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', N'CONSTRAINT', N'PK_Store_CustomerID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'CONSTRAINT', @level2name = N'PK_Store_CustomerID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'CONSTRAINT', @level2name = N'PK_Store_CustomerID'
END
GO
-----------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; INDEX = PXML_Store_Demographics;
-----------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', N'INDEX', N'PXML_Store_Demographics'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary XML index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'INDEX', @level2name = N'PXML_Store_Demographics'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary XML index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'INDEX', @level2name = N'PXML_Store_Demographics'
END
GO
--------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = Store; TRIGGER = iStore;
--------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'Store', N'TRIGGER', N'iStore'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'AFTER INSERT trigger inserting Store only if the Customer does not exist in the Individual table.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'TRIGGER', @level2name = N'iStore'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'AFTER INSERT trigger inserting Store only if the Customer does not exist in the Individual table.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'Store', @level2type = N'TRIGGER', @level2name = N'iStore'
END
GO
----------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = StoreContact; 
----------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'StoreContact', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping stores and their employees.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Cross-reference table mapping stores and their employees.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = default, @level2name = default
END
GO
------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = StoreContact; COLUMN = CustomerID;
------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'StoreContact', N'COLUMN', N'CustomerID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Store identification number. Foreign key to Customer.CustomerID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Store identification number. Foreign key to Customer.CustomerID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'COLUMN', @level2name = N'CustomerID'
END
GO
-----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = StoreContact; COLUMN = ContactID;
-----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'StoreContact', N'COLUMN', N'ContactID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Contact (store employee) identification number. Foreign key to Contact.ContactID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'COLUMN', @level2name = N'ContactID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Contact (store employee) identification number. Foreign key to Contact.ContactID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'COLUMN', @level2name = N'ContactID'
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = StoreContact; COLUMN = ContactTypeID;
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'StoreContact', N'COLUMN', N'ContactTypeID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Contact type such as owner or purchasing agent. Foreign key to ContactType.ContactTypeID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'COLUMN', @level2name = N'ContactTypeID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Contact type such as owner or purchasing agent. Foreign key to ContactType.ContactTypeID.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'COLUMN', @level2name = N'ContactTypeID'
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = StoreContact; COLUMN = rowguid;
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'StoreContact', N'COLUMN', N'rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'COLUMN', @level2name = N'rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'COLUMN', @level2name = N'rowguid'
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = StoreContact; COLUMN = ModifiedDate;
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'StoreContact', N'COLUMN', N'ModifiedDate'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Date and time the record was last updated.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'COLUMN', @level2name = N'ModifiedDate'
END
GO
------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = StoreContact; INDEX = AK_StoreContact_rowguid;
------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'StoreContact', N'INDEX', N'AK_StoreContact_rowguid'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'INDEX', @level2name = N'AK_StoreContact_rowguid'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Unique nonclustered index. Used to support replication samples.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'INDEX', @level2name = N'AK_StoreContact_rowguid'
END
GO
--------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = StoreContact; INDEX = IX_StoreContact_ContactID;
--------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'StoreContact', N'INDEX', N'IX_StoreContact_ContactID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'INDEX', @level2name = N'IX_StoreContact_ContactID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'INDEX', @level2name = N'IX_StoreContact_ContactID'
END
GO
------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = StoreContact; INDEX = IX_StoreContact_ContactTypeID;
------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'StoreContact', N'INDEX', N'IX_StoreContact_ContactTypeID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'INDEX', @level2name = N'IX_StoreContact_ContactTypeID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Nonclustered index.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'INDEX', @level2name = N'IX_StoreContact_ContactTypeID'
END
GO
------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; TABLE = StoreContact; CONSTRAINT = PK_StoreContact_CustomerID_ContactID;
------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'TABLE', N'StoreContact', N'CONSTRAINT', N'PK_StoreContact_CustomerID_ContactID'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'CONSTRAINT', @level2name = N'PK_StoreContact_CustomerID_ContactID'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Primary key (clustered) constraint', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'TABLE', @level1name = N'StoreContact', @level2type = N'CONSTRAINT', @level2name = N'PK_StoreContact_CustomerID_ContactID'
END
GO
---------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = HumanResources; VIEW = vEmployee; 
---------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'HumanResources', N'VIEW', N'vEmployee', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Employee names and addresses.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vEmployee', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Employee names and addresses.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vEmployee', @level2type = default, @level2name = default
END
GO
-------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = HumanResources; VIEW = vEmployeeDepartment; 
-------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'HumanResources', N'VIEW', N'vEmployeeDepartment', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Returns employee name, title, and current department.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vEmployeeDepartment', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Returns employee name, title, and current department.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vEmployeeDepartment', @level2type = default, @level2name = default
END
GO
--------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = HumanResources; VIEW = vEmployeeDepartmentHistory; 
--------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'HumanResources', N'VIEW', N'vEmployeeDepartmentHistory', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Returns employee name and current and previous departments.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vEmployeeDepartmentHistory', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Returns employee name and current and previous departments.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vEmployeeDepartmentHistory', @level2type = default, @level2name = default
END
GO
-------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = HumanResources; VIEW = vJobCandidate; 
-------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'HumanResources', N'VIEW', N'vJobCandidate', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Job candidate names and resumes.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vJobCandidate', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Job candidate names and resumes.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vJobCandidate', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = HumanResources; VIEW = vJobCandidateEducation; 
----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'HumanResources', N'VIEW', N'vJobCandidateEducation', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Displays the content from each education related element in the xml column Resume in the HumanResources.JobCandidate table. The content has been localized into French, Simplified Chinese and Thai. Some data may not display correctly unless supplemental language support is installed.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vJobCandidateEducation', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Displays the content from each education related element in the xml column Resume in the HumanResources.JobCandidate table. The content has been localized into French, Simplified Chinese and Thai. Some data may not display correctly unless supplemental language support is installed.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vJobCandidateEducation', @level2type = default, @level2name = default
END
GO
-----------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = HumanResources; VIEW = vJobCandidateEmployment; 
-----------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'HumanResources', N'VIEW', N'vJobCandidateEmployment', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Displays the content from each employement history related element in the xml column Resume in the HumanResources.JobCandidate table. The content has been localized into French, Simplified Chinese and Thai. Some data may not display correctly unless supplemental language support is installed.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vJobCandidateEmployment', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Displays the content from each employement history related element in the xml column Resume in the HumanResources.JobCandidate table. The content has been localized into French, Simplified Chinese and Thai. Some data may not display correctly unless supplemental language support is installed.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'VIEW', @level1name = N'vJobCandidateEmployment', @level2type = default, @level2name = default
END
GO
--------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Person; VIEW = vAdditionalContactInfo; 
--------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Person', N'VIEW', N'vAdditionalContactInfo', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Displays the contact name and content from each element in the xml column AdditionalContactInfo for that person.', @level0type = N'SCHEMA', @level0name = N'Person', @level1type = N'VIEW', @level1name = N'vAdditionalContactInfo', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Displays the contact name and content from each element in the xml column AdditionalContactInfo for that person.', @level0type = N'SCHEMA', @level0name = N'Person', @level1type = N'VIEW', @level1name = N'vAdditionalContactInfo', @level2type = default, @level2name = default
END
GO
-------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Person; VIEW = vStateProvinceCountryRegion; 
-------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Person', N'VIEW', N'vStateProvinceCountryRegion', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Joins StateProvince table with CountryRegion table.', @level0type = N'SCHEMA', @level0name = N'Person', @level1type = N'VIEW', @level1name = N'vStateProvinceCountryRegion', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Joins StateProvince table with CountryRegion table.', @level0type = N'SCHEMA', @level0name = N'Person', @level1type = N'VIEW', @level1name = N'vStateProvinceCountryRegion', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Person; VIEW = vStateProvinceCountryRegion; INDEX = IX_vStateProvinceCountryRegion;
----------------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Person', N'VIEW', N'vStateProvinceCountryRegion', N'INDEX', N'IX_vStateProvinceCountryRegion'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Clustered index on the view vStateProvinceCountryRegion.', @level0type = N'SCHEMA', @level0name = N'Person', @level1type = N'VIEW', @level1name = N'vStateProvinceCountryRegion', @level2type = N'INDEX', @level2name = N'IX_vStateProvinceCountryRegion'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Clustered index on the view vStateProvinceCountryRegion.', @level0type = N'SCHEMA', @level0name = N'Person', @level1type = N'VIEW', @level1name = N'vStateProvinceCountryRegion', @level2type = N'INDEX', @level2name = N'IX_vStateProvinceCountryRegion'
END
GO
------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Production; VIEW = vProductAndDescription; 
------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'VIEW', N'vProductAndDescription', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Product names and descriptions. Product descriptions are provided in multiple languages.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'VIEW', @level1name = N'vProductAndDescription', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Product names and descriptions. Product descriptions are provided in multiple languages.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'VIEW', @level1name = N'vProductAndDescription', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Production; VIEW = vProductAndDescription; INDEX = IX_vProductAndDescription;
----------------------------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'VIEW', N'vProductAndDescription', N'INDEX', N'IX_vProductAndDescription'))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Clustered index on the view vProductAndDescription.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'VIEW', @level1name = N'vProductAndDescription', @level2type = N'INDEX', @level2name = N'IX_vProductAndDescription'
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Clustered index on the view vProductAndDescription.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'VIEW', @level1name = N'vProductAndDescription', @level2type = N'INDEX', @level2name = N'IX_vProductAndDescription'
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Production; VIEW = vProductModelCatalogDescription; 
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'VIEW', N'vProductModelCatalogDescription', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Displays the content from each element in the xml column CatalogDescription for each product in the Production.ProductModel table that has catalog data.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'VIEW', @level1name = N'vProductModelCatalogDescription', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Displays the content from each element in the xml column CatalogDescription for each product in the Production.ProductModel table that has catalog data.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'VIEW', @level1name = N'vProductModelCatalogDescription', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Production; VIEW = vProductModelInstructions; 
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Production', N'VIEW', N'vProductModelInstructions', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Displays the content from each element in the xml column Instructions for each product in the Production.ProductModel table that has manufacturing instructions.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'VIEW', @level1name = N'vProductModelInstructions', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Displays the content from each element in the xml column Instructions for each product in the Production.ProductModel table that has manufacturing instructions.', @level0type = N'SCHEMA', @level0name = N'Production', @level1type = N'VIEW', @level1name = N'vProductModelInstructions', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Purchasing; VIEW = vVendor; 
---------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Purchasing', N'VIEW', N'vVendor', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Vendor (company) names and addresses and the names of vendor employees to contact.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'VIEW', @level1name = N'vVendor', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Vendor (company) names and addresses and the names of vendor employees to contact.', @level0type = N'SCHEMA', @level0name = N'Purchasing', @level1type = N'VIEW', @level1name = N'vVendor', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; VIEW = vIndividualCustomer; 
----------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'VIEW', N'vIndividualCustomer', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Individual customers (names and addresses) that purchase Adventure Works Cycles products online.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'VIEW', @level1name = N'vIndividualCustomer', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Individual customers (names and addresses) that purchase Adventure Works Cycles products online.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'VIEW', @level1name = N'vIndividualCustomer', @level2type = default, @level2name = default
END
GO
--------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; VIEW = vIndividualDemographics; 
--------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'VIEW', N'vIndividualDemographics', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Displays the content from each element in the xml column Demographics for each customer in the Sales.Individual table.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'VIEW', @level1name = N'vIndividualDemographics', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Displays the content from each element in the xml column Demographics for each customer in the Sales.Individual table.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'VIEW', @level1name = N'vIndividualDemographics', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; VIEW = vSalesPerson; 
---------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'VIEW', N'vSalesPerson', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Sales representiatives (names and addresses) and their sales-related information.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'VIEW', @level1name = N'vSalesPerson', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Sales representiatives (names and addresses) and their sales-related information.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'VIEW', @level1name = N'vSalesPerson', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; VIEW = vSalesPersonSalesByFiscalYears; 
---------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'VIEW', N'vSalesPersonSalesByFiscalYears', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Uses PIVOT to return aggregated sales information for each sales representative.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'VIEW', @level1name = N'vSalesPersonSalesByFiscalYears', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Uses PIVOT to return aggregated sales information for each sales representative.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'VIEW', @level1name = N'vSalesPersonSalesByFiscalYears', @level2type = default, @level2name = default
END
GO
-------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = Sales; VIEW = vStoreWithDemographics; 
-------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'Sales', N'VIEW', N'vStoreWithDemographics', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Stores (names and addresses) that sell Adventure Works Cycles products to consumers.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'VIEW', @level1name = N'vStoreWithDemographics', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Stores (names and addresses) that sell Adventure Works Cycles products to consumers.', @level0type = N'SCHEMA', @level0name = N'Sales', @level1type = N'VIEW', @level1name = N'vStoreWithDemographics', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = dbo; PROCEDURE = uspGetBillOfMaterials; 
---------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'dbo', N'PROCEDURE', N'uspGetBillOfMaterials', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Stored procedure using a recursive query to return a multi-level bill of material for the specified ProductID.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspGetBillOfMaterials', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Stored procedure using a recursive query to return a multi-level bill of material for the specified ProductID.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspGetBillOfMaterials', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = dbo; PROCEDURE = uspGetEmployeeManagers; 
----------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'dbo', N'PROCEDURE', N'uspGetEmployeeManagers', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Stored procedure using a recursive query to return the direct and indirect managers of the specified employee.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspGetEmployeeManagers', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Stored procedure using a recursive query to return the direct and indirect managers of the specified employee.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspGetEmployeeManagers', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = dbo; PROCEDURE = uspGetManagerEmployees; 
----------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'dbo', N'PROCEDURE', N'uspGetManagerEmployees', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Stored procedure using a recursive query to return the direct and indirect employees of the specified manager.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspGetManagerEmployees', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Stored procedure using a recursive query to return the direct and indirect employees of the specified manager.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspGetManagerEmployees', @level2type = default, @level2name = default
END
GO
------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = dbo; PROCEDURE = uspGetWhereUsedProductID; 
------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'dbo', N'PROCEDURE', N'uspGetWhereUsedProductID', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Stored procedure using a recursive query to return all components or assemblies that directly or indirectly use the specified ProductID.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspGetWhereUsedProductID', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Stored procedure using a recursive query to return all components or assemblies that directly or indirectly use the specified ProductID.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspGetWhereUsedProductID', @level2type = default, @level2name = default
END
GO
-----------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = dbo; PROCEDURE = uspLogError; 
-----------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'dbo', N'PROCEDURE', N'uspLogError', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Logs error information in the ErrorLog table about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without inserting error information.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspLogError', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Logs error information in the ErrorLog table about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without inserting error information.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspLogError', @level2type = default, @level2name = default
END
GO
-------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = dbo; PROCEDURE = uspPrintError; 
-------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'dbo', N'PROCEDURE', N'uspPrintError', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Prints error information about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without printing any error information.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspPrintError', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Prints error information about the error that caused execution to jump to the CATCH block of a TRY...CATCH construct. Should be executed from within the scope of a CATCH block otherwise it will return without printing any error information.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'PROCEDURE', @level1name = N'uspPrintError', @level2type = default, @level2name = default
END
GO
------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = HumanResources; PROCEDURE = uspUpdateEmployeeHireInfo; 
------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'HumanResources', N'PROCEDURE', N'uspUpdateEmployeeHireInfo', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Updates the Employee table and inserts a new row in the EmployeePayHistory table with the values specified in the input parameters.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'PROCEDURE', @level1name = N'uspUpdateEmployeeHireInfo', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Updates the Employee table and inserts a new row in the EmployeePayHistory table with the values specified in the input parameters.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'PROCEDURE', @level1name = N'uspUpdateEmployeeHireInfo', @level2type = default, @level2name = default
END
GO
---------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = HumanResources; PROCEDURE = uspUpdateEmployeeLogin; 
---------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'HumanResources', N'PROCEDURE', N'uspUpdateEmployeeLogin', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Updates the Employee table with the values specified in the input parameters for the given EmployeeID.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'PROCEDURE', @level1name = N'uspUpdateEmployeeLogin', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Updates the Employee table with the values specified in the input parameters for the given EmployeeID.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'PROCEDURE', @level1name = N'uspUpdateEmployeeLogin', @level2type = default, @level2name = default
END
GO
----------------------------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = HumanResources; PROCEDURE = uspUpdateEmployeePersonalInfo; 
----------------------------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'HumanResources', N'PROCEDURE', N'uspUpdateEmployeePersonalInfo', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Updates the Employee table with the values specified in the input parameters for the given EmployeeID.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'PROCEDURE', @level1name = N'uspUpdateEmployeePersonalInfo', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Updates the Employee table with the values specified in the input parameters for the given EmployeeID.', @level0type = N'SCHEMA', @level0name = N'HumanResources', @level1type = N'PROCEDURE', @level1name = N'uspUpdateEmployeePersonalInfo', @level2type = default, @level2name = default
END
GO
-----------------------------------------------------------------------------------------------
-- 25.12.2011 20:05:40 MS_Description for SCHEMA = dbo; FUNCTION = ufnGetContactInformation; 
-----------------------------------------------------------------------------------------------
IF EXISTS(SELECT * FROM fn_listextendedproperty(N'MS_Description', N'SCHEMA', N'dbo', N'FUNCTION', N'ufnGetContactInformation', default, default))
BEGIN
    EXEC sp_updateextendedproperty @name = N'MS_Description', @value = N'Table value function returning the first name, last name, job title and contact type for a given contact.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'FUNCTION', @level1name = N'ufnGetContactInformation', @level2type = default, @level2name = default
END
ELSE
BEGIN
    EXEC sp_addextendedproperty @name = N'MS_Description', @value = N'Table value function returning the first name, last name, job title and contact type for a given contact.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'FUNCTION', @level1name = N'ufnGetContactInformation', @level2type = default, @level2name = default
END
GO
