Editing Sales.Store (table)

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
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
 
| Sales.Store
 
| Sales.Store
|- valign="top"
+
|-
| '''Description
 
| Customers (resellers) of Adventure Works products.
 
 
|}
 
|}
  
=== 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 17: Line 15:
 
| '''Nullable
 
| '''Nullable
 
| '''Default
 
| '''Default
| '''Description
+
| '''PK
 
+
| '''Index
|- valign="top"
+
 +
|-
 
| CustomerID
 
| CustomerID
 
| int
 
| int
 
| not null
 
| not null
 
|  
 
|  
| Primary key. Foreign key to Customer.CustomerID.
+
| PK_Store_CustomerID
|- valign="top"
+
|
 +
|-
 
| Name
 
| Name
 
| dbo.Name
 
| dbo.Name
 
| not null
 
| not null
 
|  
 
|  
| Name of the store.
+
|  
|- valign="top"
+
|
 +
|-
 
| SalesPersonID
 
| SalesPersonID
 
| int
 
| int
 
| null
 
| null
 
|  
 
|  
| ID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID.
+
|  
|- valign="top"
+
| IX_Store_SalesPersonID
 +
|-
 
| Demographics
 
| Demographics
 
| xml
 
| xml
 
| null
 
| null
 
|  
 
|  
| Demographic informationg about the store such as the number of employees, annual sales and store type.
+
|  
|- valign="top"
+
| PXML_Store_Demographics
 +
|-
 
| rowguid
 
| rowguid
 
| uniqueidentifier
 
| uniqueidentifier
 
| not null
 
| not null
 
| (newid())
 
| (newid())
| ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.
+
|  
|- valign="top"
+
| AK_Store_rowguid
 +
|-
 
| 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_Store_CustomerID
 
| CustomerID
 
|}
 
  
=== Indexes ===
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
| '''Index
 
| '''Type
 
| '''Columns
 
  
|- valign="top"
 
| AK_Store_rowguid
 
| Unique
 
| rowguid
 
|- valign="top"
 
| IX_Store_SalesPersonID
 
|
 
| SalesPersonID
 
|- valign="top"
 
| PXML_Store_Demographics
 
|
 
| Demographics
 
|}
 
 
=== Foreign Keys ===
 
 
{| 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 94: Line 69:
 
| '''Column
 
| '''Column
 
| '''Referenced Column
 
| '''Referenced Column
 
+
|- valign="top"
+
|-
 
| [[Sales.Customer_(table)|Sales.Customer]]
 
| [[Sales.Customer_(table)|Sales.Customer]]
 
| CustomerID
 
| CustomerID
 
| CustomerID
 
| CustomerID
|- valign="top"
+
|-
 
| [[Sales.SalesPerson_(table)|Sales.SalesPerson]]
 
| [[Sales.SalesPerson_(table)|Sales.SalesPerson]]
 
| SalesPersonID
 
| SalesPersonID
Line 105: Line 80:
 
|}
 
|}
  
=== 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 111: Line 86:
 
| '''Column
 
| '''Column
 
| '''Referencing Column
 
| '''Referencing Column
 
+
|- valign="top"
+
|-
 
| [[Sales.StoreContact_(table)|Sales.StoreContact]]
 
| [[Sales.StoreContact_(table)|Sales.StoreContact]]
 
| CustomerID
 
| CustomerID
Line 118: Line 93:
 
|}
 
|}
  
=== 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"
| '''Trigger
+
| '''Triggers
 
| '''Type
 
| '''Type
 
+
|- valign="top"
+
|-
 
| iStore
 
| iStore
 
| ON INSERT
 
| ON INSERT
 
|}
 
|}
 
==== Trigger iStore ====
 
<pre>
 
CREATE TRIGGER [Sales].[iStore] ON [Sales].[Store]
 
AFTER INSERT AS
 
BEGIN
 
    DECLARE @Count int;
 
 
    SET @Count = @@ROWCOUNT;
 
    IF @Count = 0
 
        RETURN;
 
 
    SET NOCOUNT ON;
 
 
    BEGIN TRY
 
        -- Only allow the Customer to be a Store OR Individual
 
        IF EXISTS (SELECT * FROM inserted INNER JOIN [Sales].[Individual]
 
            ON inserted.[CustomerID] = [Sales].[Individual].[CustomerID])
 
        BEGIN
 
            -- 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.Name_(type)|dbo.Name]]
 
 
|
 
|
 
|- valign="top"
 
| Schema
 
| Schema
 
| [[Sales_(schema)|Sales]]
 
 
|
 
|
 
|- valign="top"
 
| Data Type
 
| XML Schema Collection
 
| [[Sales.StoreSurveySchemaCollection_(xml schema collection)|Sales.StoreSurveySchemaCollection]]
 
 
|
 
|
 
|- valign="top"
 
| Select
 
| Table
 
| [[Sales.Individual_(table)|Sales.Individual]]
 
 
| Trigger
 
| iStore
 
|- valign="top"
 
| Execute
 
| Procedure
 
| [[dbo.uspLogError_(procedure)|dbo.uspLogError]]
 
 
| Trigger
 
| iStore
 
|- valign="top"
 
| Execute
 
| Procedure
 
| [[dbo.uspPrintError_(procedure)|dbo.uspPrintError]]
 
 
| Trigger
 
| iStore
 
|}
 
 
=== Dependencies ===
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
| '''Reference Type
 
| '''Object Type
 
| '''Referencing Object
 
 
| '''Child Type
 
| '''Child Object
 
 
|- valign="top"
 
| Select
 
| View
 
| [[Sales.vStoreWithDemographics_(view)|Sales.vStoreWithDemographics]]
 
 
|
 
|
 
|- valign="top"
 
| Select
 
| Table
 
| [[Sales.Individual_(table)|Sales.Individual]]
 
 
| Trigger
 
| iuIndividual
 
|}
 
 
  
 
== automatically generated ==
 
== automatically generated ==
Line 256: Line 110:
 
| '''Table
 
| '''Table
 
| Sales.Store
 
| Sales.Store
|- valign="top"
+
|-
 +
 
 
| '''Description
 
| '''Description
 
| Customers (resellers) of Adventure Works products.
 
| Customers (resellers) of Adventure Works products.
 
|-
 
|-
 +
 
|}
 
|}
  
Line 269: Line 125:
 
| '''Nullable
 
| '''Nullable
 
| '''Default
 
| '''Default
| '''Description / PK / Index
+
| '''Description
 +
| '''PK / Index
 
 
|- valign="top"
+
|-
 
| CustomerID
 
| CustomerID
 
| int
 
| int
 
| not null
 
| not null
 
|  
 
|  
| Primary key. Foreign key to Customer.CustomerID.<br />PK_Store_CustomerID
+
| Primary key. Foreign key to Customer.CustomerID.
|- valign="top"
+
| PK_Store_CustomerID
 +
|-
 
| Name
 
| Name
 
| Name
 
| Name
 
| not null
 
| not null
 
|  
 
|  
| Name of the store.<br />
+
| Name of the store.
|- valign="top"
+
|
 +
|-
 
| SalesPersonID
 
| SalesPersonID
 
| int
 
| int
 
| null
 
| null
 
|  
 
|  
| ID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID.<br />IX_Store_SalesPersonID
+
| ID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID.
|- valign="top"
+
| IX_Store_SalesPersonID
 +
|-
 
| Demographics
 
| Demographics
 
| XML
 
| XML
 
| null
 
| null
 
|  
 
|  
| Demographic informationg about the store such as the number of employees, annual sales and store type.<br />PXML_Store_Demographics
+
| Demographic informationg about the store such as the number of employees, annual sales and store type.
|- valign="top"
+
| PXML_Store_Demographics
 +
|-
 
| rowguid
 
| rowguid
 
| uniqueidentifier
 
| uniqueidentifier
 
| not null
 
| not null
 
| (NEWID())
 
| (NEWID())
| ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.<br />AK_Store_rowguid
+
| ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.
|- valign="top"
+
| AK_Store_rowguid
 +
|-
 
| ModifiedDate
 
| ModifiedDate
 
| datetime
 
| datetime
 
| not null
 
| not null
 
| (GETDATE())
 
| (GETDATE())
| Date and time the record was last updated.<br />
+
| Date and time the record was last updated.
 +
|
 
|}
 
|}
  
Line 349: Line 212:
 
| iStore
 
| iStore
 
| ON INSERT
 
| ON INSERT
|}
 
 
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
| '''Dependency Type
 
| '''Object Type
 
| '''Referenced Object
 
 
| '''Child Type
 
| '''Child Object
 
 
|-
 
| Data Type
 
| Type
 
| [[dbo.Name_(type)|dbo.Name]]
 
 
|
 
|
 
|-
 
| Schema
 
| Schema
 
| [[Sales_(schema)|Sales]]
 
 
|
 
|
 
|-
 
| Data Type
 
| XML Schema Collection
 
| [[Sales.StoreSurveySchemaCollection_(xml_schema_collection)|Sales.StoreSurveySchemaCollection]]
 
 
|
 
|
 
|-
 
| Select
 
| Table
 
| [[Sales.Individual_(table)|Sales.Individual]]
 
 
| Trigger
 
| iStore
 
|-
 
| Execute
 
| Procedure
 
| [[dbo.uspLogError_(procedure)|dbo.uspLogError]]
 
 
| Trigger
 
| iStore
 
|-
 
| Execute
 
| Procedure
 
| [[dbo.uspPrintError_(procedure)|dbo.uspPrintError]]
 
 
| Trigger
 
| iStore
 
|}
 
 
 
{| border="1" cellpadding="5" cellspacing="0" style="border-collapse:collapse"
 
|- style="background:silver"
 
| '''Reference Type
 
| '''Object Type
 
| '''Referencing Object
 
 
| '''Child Type
 
| '''Child Object
 
 
|-
 
| Select
 
| View
 
| [[Sales.vStoreWithDemographics_(view)|Sales.vStoreWithDemographics]]
 
 
|
 
|
 
|-
 
| Select
 
| Table
 
| [[Sales.Individual_(table)|Sales.Individual]]
 
 
| Trigger
 
| iuIndividual
 
 
|}
 
|}

Please note that all contributions to dbscript Online Help may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Project:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)