wikibot[edit]
Table
|
Sales.Store
|
Description
|
Customers (resellers) of Adventure Works products.
|
Columns[edit]
Column
|
Data Type
|
Nullable
|
Default
|
Description
|
CustomerID
|
int
|
not null
|
|
Primary key. Foreign key to Customer.CustomerID.
|
Name
|
dbo.Name
|
not null
|
|
Name of the store.
|
SalesPersonID
|
int
|
null
|
|
ID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID.
|
Demographics
|
xml
|
null
|
|
Demographic informationg about the store such as the number of employees, annual sales and store type.
|
rowguid
|
uniqueidentifier
|
not null
|
(newid())
|
ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample.
|
ModifiedDate
|
datetime
|
not null
|
(getdate())
|
Date and time the record was last updated.
|
Primary Key[edit]
Primary Key
|
Columns
|
PK_Store_CustomerID
|
CustomerID
|
Indexes[edit]
Index
|
Type
|
Columns
|
AK_Store_rowguid
|
Unique
|
rowguid
|
IX_Store_SalesPersonID
|
|
SalesPersonID
|
PXML_Store_Demographics
|
|
Demographics
|
Foreign Keys[edit]
Detail Tables[edit]
Triggers[edit]
Trigger
|
Type
|
iStore
|
ON INSERT
|
Trigger iStore[edit]
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;
References[edit]
Dependencies[edit]
automatically generated[edit]
Table
|
Sales.Store
|
Description
|
Customers (resellers) of Adventure Works products.
|
Column
|
Data Type
|
Nullable
|
Default
|
Description / PK / Index
|
CustomerID
|
int
|
not null
|
|
Primary key. Foreign key to Customer.CustomerID. PK_Store_CustomerID
|
Name
|
Name
|
not null
|
|
Name of the store.
|
SalesPersonID
|
int
|
null
|
|
ID of the sales person assigned to the customer. Foreign key to SalesPerson.SalesPersonID. IX_Store_SalesPersonID
|
Demographics
|
XML
|
null
|
|
Demographic informationg about the store such as the number of employees, annual sales and store type. PXML_Store_Demographics
|
rowguid
|
uniqueidentifier
|
not null
|
(NEWID())
|
ROWGUIDCOL number uniquely identifying the record. Used to support a merge replication sample. AK_Store_rowguid
|
ModifiedDate
|
datetime
|
not null
|
(GETDATE())
|
Date and time the record was last updated.
|
Triggers
|
Type
|
iStore
|
ON INSERT
|