Difference between revisions of "Purchasing.Vendor (table)"

From dbscript Online Help
Jump to: navigation, search
 
(5 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
|-
+
|- valign="top"
 
| '''Table
 
| '''Table
 
| Purchasing.Vendor
 
| Purchasing.Vendor
|-
+
|- valign="top"
 +
| '''Description
 +
| Companies from whom Adventure Works Cycles purchases parts or other goods.
 
|}
 
|}
  
 
+
=== Columns ===
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
Line 15: Line 17:
 
| '''Nullable
 
| '''Nullable
 
| '''Default
 
| '''Default
| '''PK
+
| '''Description
| '''Index
+
 
+
|- valign="top"
|-
 
 
| VendorID
 
| VendorID
 
| int
 
| int
 
| not null
 
| not null
 
|  
 
|  
| PK_Vendor_VendorID
+
| Primary key for Vendor records.
|
+
|- valign="top"
|-
 
 
| AccountNumber
 
| AccountNumber
 
| dbo.AccountNumber
 
| dbo.AccountNumber
 
| not null
 
| not null
 
|  
 
|  
|  
+
| Vendor account (identification) number.
| AK_Vendor_AccountNumber
+
|- valign="top"
|-
 
 
| Name
 
| Name
 
| dbo.Name
 
| dbo.Name
 
| not null
 
| not null
 
|  
 
|  
|  
+
| Company name.
|
+
|- valign="top"
|-
 
 
| CreditRating
 
| CreditRating
 
| tinyint
 
| tinyint
 
| not null
 
| not null
 
|  
 
|  
|  
+
| 1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average
|
+
|- valign="top"
|-
 
 
| PreferredVendorStatus
 
| PreferredVendorStatus
 
| dbo.Flag
 
| dbo.Flag
 
| not null
 
| not null
 
| ((1))
 
| ((1))
|  
+
| 0 = Do not use if another vendor is available. 1 = Preferred over other vendors supplying the same product.
|
+
|- valign="top"
|-
 
 
| ActiveFlag
 
| ActiveFlag
 
| dbo.Flag
 
| dbo.Flag
 
| not null
 
| not null
 
| ((1))
 
| ((1))
|  
+
| 0 = Vendor no longer used. 1 = Vendor is actively used.
|
+
|- valign="top"
|-
 
 
| PurchasingWebServiceURL
 
| PurchasingWebServiceURL
 
| nvarchar(1024)
 
| nvarchar(1024)
 
| null
 
| null
 
|  
 
|  
|  
+
| Vendor URL.
|
+
|- valign="top"
|-
 
 
| ModifiedDate
 
| ModifiedDate
 
| datetime
 
| datetime
 
| not null
 
| not null
 
| (getdate())
 
| (getdate())
|  
+
| Date and time the record was last updated.
|  
+
|}
 +
 
 +
=== Primary Key ===
 +
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 +
|- style="background:silver"
 +
| '''Primary Key
 +
| '''Columns
 +
|- valign="top"
 +
| PK_Vendor_VendorID
 +
| VendorID
 +
|}
 +
 
 +
=== Indexes ===
 +
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 +
|- style="background:silver"
 +
| '''Index
 +
| '''Type
 +
| '''Columns
 +
 
 +
|- valign="top"
 +
| AK_Vendor_AccountNumber
 +
| Unique
 +
| AccountNumber
 
|}
 
|}
  
 +
=== Check Constraints ===
 +
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 +
|- style="background:silver"
 +
| '''Check Constraint
 +
| '''Expression
 +
| '''Description
  
 +
|- valign="top"
 +
| CK_Vendor_CreditRating
 +
| ([CreditRating]>=(1) AND [CreditRating]<=(5))
 +
| Check constraint [CreditRating] BETWEEN (1) AND (5)
 +
|}
  
 +
=== Detail Tables ===
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
Line 83: Line 111:
 
| '''Column
 
| '''Column
 
| '''Referencing Column
 
| '''Referencing Column
+
 
|-
+
|- valign="top"
 
| [[Purchasing.ProductVendor_(table)|Purchasing.ProductVendor]]
 
| [[Purchasing.ProductVendor_(table)|Purchasing.ProductVendor]]
 
| VendorID
 
| VendorID
 
| VendorID
 
| VendorID
|-
+
|- valign="top"
 
| [[Purchasing.PurchaseOrderHeader_(table)|Purchasing.PurchaseOrderHeader]]
 
| [[Purchasing.PurchaseOrderHeader_(table)|Purchasing.PurchaseOrderHeader]]
 
| VendorID
 
| VendorID
 
| VendorID
 
| VendorID
|-
+
|- valign="top"
 
| [[Purchasing.VendorAddress_(table)|Purchasing.VendorAddress]]
 
| [[Purchasing.VendorAddress_(table)|Purchasing.VendorAddress]]
 
| VendorID
 
| VendorID
 
| VendorID
 
| VendorID
|-
+
|- valign="top"
 
| [[Purchasing.VendorContact_(table)|Purchasing.VendorContact]]
 
| [[Purchasing.VendorContact_(table)|Purchasing.VendorContact]]
 
| VendorID
 
| VendorID
Line 102: Line 130:
 
|}
 
|}
  
 
+
=== Triggers ===
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
| '''Triggers
+
| '''Trigger
 
| '''Type
 
| '''Type
+
 
|-
+
|- valign="top"
 
| dVendor
 
| dVendor
 
| INSTEAD OF DELETE
 
| INSTEAD OF DELETE
 
|}
 
|}
 +
 +
==== Trigger dVendor ====
 +
<pre>
 +
CREATE TRIGGER [Purchasing].[dVendor] ON [Purchasing].[Vendor]
 +
INSTEAD OF DELETE NOT FOR REPLICATION AS
 +
BEGIN
 +
    DECLARE @Count int;
 +
 +
    SET @Count = @@ROWCOUNT;
 +
    IF @Count = 0
 +
        RETURN;
 +
 +
    SET NOCOUNT ON;
 +
 +
    BEGIN TRY
 +
        DECLARE @DeleteCount int;
 +
 +
        SELECT @DeleteCount = COUNT(*) FROM deleted;
 +
        IF @DeleteCount > 0
 +
        BEGIN
 +
            RAISERROR
 +
                (N'Vendors cannot be deleted. They can only be marked as not active.', -- Message
 +
                10, -- Severity.
 +
                1); -- State.
 +
 +
        -- Rollback any active or uncommittable transactions
 +
            IF @@TRANCOUNT > 0
 +
            BEGIN
 +
                ROLLBACK TRANSACTION;
 +
            END
 +
        END;
 +
    END TRY
 +
    BEGIN CATCH
 +
        EXECUTE [dbo].[uspPrintError];
 +
 +
        -- Rollback any active or uncommittable transactions before
 +
        -- inserting information in the ErrorLog
 +
        IF @@TRANCOUNT > 0
 +
        BEGIN
 +
            ROLLBACK TRANSACTION;
 +
        END
 +
 +
        EXECUTE [dbo].[uspLogError];
 +
    END CATCH;
 +
END;
 +
</pre>
 +
 +
=== References ===
 +
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 +
|- style="background:silver"
 +
| '''Dependency Type
 +
| '''Object Type
 +
| '''Referenced Object
 +
 +
| '''Child Type
 +
| '''Child Object
 +
 +
|- valign="top"
 +
| Data Type
 +
| Type
 +
| [[dbo.AccountNumber_(type)|dbo.AccountNumber]]
 +
 +
|
 +
|
 +
|- valign="top"
 +
| Data Type
 +
| Type
 +
| [[dbo.Flag_(type)|dbo.Flag]]
 +
 +
|
 +
|
 +
|- valign="top"
 +
| Data Type
 +
| Type
 +
| [[dbo.Name_(type)|dbo.Name]]
 +
 +
|
 +
|
 +
|- valign="top"
 +
| Schema
 +
| Schema
 +
| [[Purchasing_(schema)|Purchasing]]
 +
 +
|
 +
|
 +
|- valign="top"
 +
| Execute
 +
| Procedure
 +
| [[dbo.uspLogError_(procedure)|dbo.uspLogError]]
 +
 +
| Trigger
 +
| dVendor
 +
|- valign="top"
 +
| Execute
 +
| Procedure
 +
| [[dbo.uspPrintError_(procedure)|dbo.uspPrintError]]
 +
 +
| Trigger
 +
| dVendor
 +
|}
 +
 +
=== Dependencies ===
 +
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 +
|- style="background:silver"
 +
| '''Reference Type
 +
| '''Object Type
 +
| '''Referencing Object
 +
 +
|- valign="top"
 +
| Select
 +
| View
 +
| [[Purchasing.vVendor_(view)|Purchasing.vVendor]]
 +
 +
|}
 +
 +
 
== automatically generated ==
 
== automatically generated ==
  
Line 119: Line 263:
 
| Purchasing.Vendor
 
| Purchasing.Vendor
 
|- valign="top"
 
|- valign="top"
 
 
| '''Description
 
| '''Description
 
| Companies from whom Adventure Works Cycles purchases parts or other goods.
 
| Companies from whom Adventure Works Cycles purchases parts or other goods.
 
|-
 
|-
 
 
|}
 
|}
  
Line 225: Line 367:
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
 +
| '''Dependency Type
 +
| '''Object Type
 
| '''Referenced Object
 
| '''Referenced Object
| '''Object Type
+
 
| '''Dependency Type
+
| '''Child Type
+
| '''Child Object
 +
 
 
|-
 
|-
 +
| Data Type
 +
| Type
 
| [[dbo.AccountNumber_(type)|dbo.AccountNumber]]
 
| [[dbo.AccountNumber_(type)|dbo.AccountNumber]]
 +
 +
|
 +
|
 +
|-
 +
| Data Type
 
| Type
 
| Type
 +
| [[dbo.Flag_(type)|dbo.Flag]]
 +
 +
|
 +
|
 +
|-
 
| Data Type
 
| Data Type
|-
 
| [[dbo.Flag_(type)|dbo.Flag]]
 
 
| Type
 
| Type
| Data Type
+
| [[dbo.Name_(type)|dbo.Name]]
 +
 
 +
|
 +
|
 
|-
 
|-
| [[dbo.Name_(type)|dbo.Name]]
+
| Schema
| Type
+
| Schema
| Data Type
+
| [[Purchasing_(schema)|Purchasing]]
 +
 
 +
|  
 +
|  
 
|-
 
|-
 +
| Execute
 +
| Procedure
 
| [[dbo.uspLogError_(procedure)|dbo.uspLogError]]
 
| [[dbo.uspLogError_(procedure)|dbo.uspLogError]]
 +
 +
| Trigger
 +
| dVendor
 +
|-
 +
| Execute
 
| Procedure
 
| Procedure
| Execute
 
|-
 
 
| [[dbo.uspPrintError_(procedure)|dbo.uspPrintError]]
 
| [[dbo.uspPrintError_(procedure)|dbo.uspPrintError]]
| Procedure
+
 
| Execute
+
| Trigger
 +
| dVendor
 
|}
 
|}
  
Line 254: Line 421:
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
|- style="background:silver"
 +
| '''Reference Type
 +
| '''Object Type
 
| '''Referencing Object
 
| '''Referencing Object
| '''Object Type
+
 
| '''Reference Type
 
 
 
|-
 
|-
 +
| Select
 +
| View
 
| [[Purchasing.vVendor_(view)|Purchasing.vVendor]]
 
| [[Purchasing.vVendor_(view)|Purchasing.vVendor]]
| View
+
 
| Select
 
 
|}
 
|}

Latest revision as of 23:17, 23 June 2010

wikibot[edit]

Table Purchasing.Vendor
Description Companies from whom Adventure Works Cycles purchases parts or other goods.

Columns[edit]

Column Data Type Nullable Default Description
VendorID int not null Primary key for Vendor records.
AccountNumber dbo.AccountNumber not null Vendor account (identification) number.
Name dbo.Name not null Company name.
CreditRating tinyint not null 1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average
PreferredVendorStatus dbo.Flag not null ((1)) 0 = Do not use if another vendor is available. 1 = Preferred over other vendors supplying the same product.
ActiveFlag dbo.Flag not null ((1)) 0 = Vendor no longer used. 1 = Vendor is actively used.
PurchasingWebServiceURL nvarchar(1024) null Vendor URL.
ModifiedDate datetime not null (getdate()) Date and time the record was last updated.

Primary Key[edit]

Primary Key Columns
PK_Vendor_VendorID VendorID

Indexes[edit]

Index Type Columns
AK_Vendor_AccountNumber Unique AccountNumber

Check Constraints[edit]

Check Constraint Expression Description
CK_Vendor_CreditRating ([CreditRating]>=(1) AND [CreditRating]<=(5)) Check constraint [CreditRating] BETWEEN (1) AND (5)

Detail Tables[edit]

Detail Table Column Referencing Column
Purchasing.ProductVendor VendorID VendorID
Purchasing.PurchaseOrderHeader VendorID VendorID
Purchasing.VendorAddress VendorID VendorID
Purchasing.VendorContact VendorID VendorID

Triggers[edit]

Trigger Type
dVendor INSTEAD OF DELETE

Trigger dVendor[edit]

CREATE TRIGGER [Purchasing].[dVendor] ON [Purchasing].[Vendor] 
INSTEAD OF DELETE NOT FOR REPLICATION AS 
BEGIN
    DECLARE @Count int;

    SET @Count = @@ROWCOUNT;
    IF @Count = 0 
        RETURN;

    SET NOCOUNT ON;

    BEGIN TRY
        DECLARE @DeleteCount int;

        SELECT @DeleteCount = COUNT(*) FROM deleted;
        IF @DeleteCount > 0 
        BEGIN
            RAISERROR
                (N'Vendors cannot be deleted. They can only be marked as not active.', -- Message
                10, -- Severity.
                1); -- State.

        -- Rollback any active or uncommittable transactions
            IF @@TRANCOUNT > 0
            BEGIN
                ROLLBACK TRANSACTION;
            END
        END;
    END TRY
    BEGIN CATCH
        EXECUTE [dbo].[uspPrintError];

        -- Rollback any active or uncommittable transactions before
        -- inserting information in the ErrorLog
        IF @@TRANCOUNT > 0
        BEGIN
            ROLLBACK TRANSACTION;
        END

        EXECUTE [dbo].[uspLogError];
    END CATCH;
END;

References[edit]

Dependency Type Object Type Referenced Object Child Type Child Object
Data Type Type dbo.AccountNumber
Data Type Type dbo.Flag
Data Type Type dbo.Name
Schema Schema Purchasing
Execute Procedure dbo.uspLogError Trigger dVendor
Execute Procedure dbo.uspPrintError Trigger dVendor

Dependencies[edit]

Reference Type Object Type Referencing Object
Select View Purchasing.vVendor


automatically generated[edit]

Table Purchasing.Vendor
Description Companies from whom Adventure Works Cycles purchases parts or other goods.


Column Data Type Nullable Default Description / PK / Index
VendorID int not null Primary key for Vendor records.
PK_Vendor_VendorID
AccountNumber AccountNumber not null Vendor account (identification) number.
AK_Vendor_AccountNumber
Name Name not null Company name.
CreditRating tinyint not null 1 = Superior, 2 = Excellent, 3 = Above average, 4 = Average, 5 = Below average
PreferredVendorStatus Flag not null (1) 0 = Do not use if another vendor is available. 1 = Preferred over other vendors supplying the same product.
ActiveFlag Flag not null (1) 0 = Vendor no longer used. 1 = Vendor is actively used.
PurchasingWebServiceURL nvarchar(1024) null Vendor URL.
ModifiedDate datetime not null (GETDATE()) Date and time the record was last updated.


Detail Table Column Referencing Column
Purchasing.ProductVendor VendorID VendorID
Purchasing.PurchaseOrderHeader VendorID VendorID
Purchasing.VendorAddress VendorID VendorID
Purchasing.VendorContact VendorID VendorID


Triggers Type
dVendor INSTEAD OF DELETE


Dependency Type Object Type Referenced Object Child Type Child Object
Data Type Type dbo.AccountNumber
Data Type Type dbo.Flag
Data Type Type dbo.Name
Schema Schema Purchasing
Execute Procedure dbo.uspLogError Trigger dVendor
Execute Procedure dbo.uspPrintError Trigger dVendor


Reference Type Object Type Referencing Object
Select View Purchasing.vVendor