-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9edc53
commit fc32c50
Showing
40 changed files
with
762 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -440,3 +440,4 @@ $RECYCLE.BIN/ | |
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
.vscode/settings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# If you are using this example in your oun repository, | ||
# you need to uncomment the lines below: | ||
# resources: | ||
# repositories: | ||
# - repository: UDP | ||
# type: github | ||
# endpoint: devopsnights | ||
# name: devopsnights/UDP | ||
# ref: refs/heads/main | ||
|
||
trigger: | ||
- main | ||
- feature/* | ||
|
||
# trigger: | ||
# branches: | ||
# include: | ||
# - main | ||
# - feature/* | ||
# paths: | ||
# include: | ||
# - examples/sqlserver | ||
|
||
pool: | ||
vmImage: 'windows-latest' | ||
|
||
extends: | ||
# If you are using this example in your oun repository, | ||
# you need to uncomment the next line and comment the line streight below | ||
#template: src\orchestrator.yml@UDP | ||
template: ..\..\src\orchestrator.yml | ||
parameters: | ||
serviceConnection: 'AzureServiceConnection' | ||
environments: | ||
- dev | ||
# - uat | ||
# - prd | ||
configuration: | ||
buildOnly: false | ||
resources: | ||
- type: sqlserver | ||
enabled: true | ||
solutionFilter: '**\sql-template.sln' | ||
deployment: | ||
type: azureWebApp | ||
name: wa-udp-dotnetcore-windows | ||
infrastructure: | ||
enabled: false | ||
application: | ||
enabled: true | ||
serverName: 'sql-udp.database.windows.net' | ||
databaseName: 'sqludp' | ||
sqlUsername: 'wesley' | ||
sqlPassword: '$(sqlPassword)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30611.23 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "sql-template", "sql-template\sql-template.sqlproj", "{59966C8C-FC3B-4F2C-A750-479BE6BDE614}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{59966C8C-FC3B-4F2C-A750-479BE6BDE614}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{59966C8C-FC3B-4F2C-A750-479BE6BDE614}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{59966C8C-FC3B-4F2C-A750-479BE6BDE614}.Debug|Any CPU.Deploy.0 = Debug|Any CPU | ||
{59966C8C-FC3B-4F2C-A750-479BE6BDE614}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{59966C8C-FC3B-4F2C-A750-479BE6BDE614}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{59966C8C-FC3B-4F2C-A750-479BE6BDE614}.Release|Any CPU.Deploy.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {39525544-4595-4F38-9233-0A3DAA1B2348} | ||
EndGlobalSection | ||
EndGlobal |
5 changes: 5 additions & 0 deletions
5
examples/sqlserver/src/sql-template/SalesLT/Sequences/SalesOrderNumber.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE SEQUENCE [SalesLT].[SalesOrderNumber] | ||
AS INT | ||
START WITH 1 | ||
INCREMENT BY 1; | ||
|
24 changes: 24 additions & 0 deletions
24
examples/sqlserver/src/sql-template/SalesLT/Tables/Address.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
CREATE TABLE [SalesLT].[Address] ( | ||
[AddressID] INT IDENTITY (1, 1) NOT NULL, | ||
[AddressLine1] NVARCHAR (60) NOT NULL, | ||
[AddressLine2] NVARCHAR (60) NULL, | ||
[City] NVARCHAR (30) NOT NULL, | ||
[StateProvince] [dbo].[Name] NOT NULL, | ||
[CountryRegion] [dbo].[Name] NOT NULL, | ||
[PostalCode] NVARCHAR (15) NOT NULL, | ||
[rowguid] UNIQUEIDENTIFIER CONSTRAINT [DF_Address_rowguid] DEFAULT (newid()) NOT NULL, | ||
[ModifiedDate] DATETIME CONSTRAINT [DF_Address_ModifiedDate] DEFAULT (getdate()) NOT NULL, | ||
CONSTRAINT [PK_Address_AddressID] PRIMARY KEY CLUSTERED ([AddressID] ASC), | ||
CONSTRAINT [AK_Address_rowguid] UNIQUE NONCLUSTERED ([rowguid] ASC) | ||
); | ||
|
||
|
||
GO | ||
CREATE NONCLUSTERED INDEX [IX_Address_AddressLine1_AddressLine2_City_StateProvince_PostalCode_CountryRegion] | ||
ON [SalesLT].[Address]([AddressLine1] ASC, [AddressLine2] ASC, [City] ASC, [StateProvince] ASC, [PostalCode] ASC, [CountryRegion] ASC); | ||
|
||
|
||
GO | ||
CREATE NONCLUSTERED INDEX [IX_Address_StateProvince] | ||
ON [SalesLT].[Address]([StateProvince] ASC); | ||
|
25 changes: 25 additions & 0 deletions
25
examples/sqlserver/src/sql-template/SalesLT/Tables/Customer.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
CREATE TABLE [SalesLT].[Customer] ( | ||
[CustomerID] INT IDENTITY (1, 1) NOT NULL, | ||
[NameStyle] [dbo].[NameStyle] CONSTRAINT [DF_Customer_NameStyle] DEFAULT ((0)) NOT NULL, | ||
[Title] NVARCHAR (8) NULL, | ||
[FirstName] [dbo].[Name] NOT NULL, | ||
[MiddleName] [dbo].[Name] NULL, | ||
[LastName] [dbo].[Name] NOT NULL, | ||
[Suffix] NVARCHAR (10) NULL, | ||
[CompanyName] NVARCHAR (128) NULL, | ||
[SalesPerson] NVARCHAR (256) NULL, | ||
[EmailAddress] NVARCHAR (50) NULL, | ||
[Phone] [dbo].[Phone] NULL, | ||
[PasswordHash] VARCHAR (128) NOT NULL, | ||
[PasswordSalt] VARCHAR (10) NOT NULL, | ||
[rowguid] UNIQUEIDENTIFIER CONSTRAINT [DF_Customer_rowguid] DEFAULT (newid()) NOT NULL, | ||
[ModifiedDate] DATETIME CONSTRAINT [DF_Customer_ModifiedDate] DEFAULT (getdate()) NOT NULL, | ||
CONSTRAINT [PK_Customer_CustomerID] PRIMARY KEY CLUSTERED ([CustomerID] ASC), | ||
CONSTRAINT [AK_Customer_rowguid] UNIQUE NONCLUSTERED ([rowguid] ASC) | ||
); | ||
|
||
|
||
GO | ||
CREATE NONCLUSTERED INDEX [IX_Customer_EmailAddress] | ||
ON [SalesLT].[Customer]([EmailAddress] ASC); | ||
|
12 changes: 12 additions & 0 deletions
12
examples/sqlserver/src/sql-template/SalesLT/Tables/CustomerAddress.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CREATE TABLE [SalesLT].[CustomerAddress] ( | ||
[CustomerID] INT NOT NULL, | ||
[AddressID] INT NOT NULL, | ||
[AddressType] [dbo].[Name] NOT NULL, | ||
[rowguid] UNIQUEIDENTIFIER CONSTRAINT [DF_CustomerAddress_rowguid] DEFAULT (newid()) NOT NULL, | ||
[ModifiedDate] DATETIME CONSTRAINT [DF_CustomerAddress_ModifiedDate] DEFAULT (getdate()) NOT NULL, | ||
CONSTRAINT [PK_CustomerAddress_CustomerID_AddressID] PRIMARY KEY CLUSTERED ([CustomerID] ASC, [AddressID] ASC), | ||
CONSTRAINT [FK_CustomerAddress_Address_AddressID] FOREIGN KEY ([AddressID]) REFERENCES [SalesLT].[Address] ([AddressID]), | ||
CONSTRAINT [FK_CustomerAddress_Customer_CustomerID] FOREIGN KEY ([CustomerID]) REFERENCES [SalesLT].[Customer] ([CustomerID]), | ||
CONSTRAINT [AK_CustomerAddress_rowguid] UNIQUE NONCLUSTERED ([rowguid] ASC) | ||
); | ||
|
7 changes: 7 additions & 0 deletions
7
examples/sqlserver/src/sql-template/SalesLT/Tables/NewTable.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE TABLE [SalesLT].[NewTable] ( | ||
[ID] INT IDENTITY (1, 1) NOT NULL, | ||
[Title] NVARCHAR (8) NULL, | ||
); | ||
|
||
|
||
GO |
30 changes: 30 additions & 0 deletions
30
examples/sqlserver/src/sql-template/SalesLT/Tables/Product.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
CREATE TABLE [SalesLT].[Product] ( | ||
[ProductID] INT IDENTITY (1, 1) NOT NULL, | ||
[Name] [dbo].[Name] NOT NULL, | ||
[ProductNumber] NVARCHAR (25) NOT NULL, | ||
[Color] NVARCHAR (15) NULL, | ||
[StandardCost] MONEY NOT NULL, | ||
[ListPrice] MONEY NOT NULL, | ||
[Size] NVARCHAR (5) NULL, | ||
[Weight] DECIMAL (8, 2) NULL, | ||
[ProductCategoryID] INT NULL, | ||
[ProductModelID] INT NULL, | ||
[SellStartDate] DATETIME NOT NULL, | ||
[SellEndDate] DATETIME NULL, | ||
[DiscontinuedDate] DATETIME NULL, | ||
[ThumbNailPhoto] VARBINARY (MAX) NULL, | ||
[ThumbnailPhotoFileName] NVARCHAR (50) NULL, | ||
[rowguid] UNIQUEIDENTIFIER CONSTRAINT [DF_Product_rowguid] DEFAULT (newid()) NOT NULL, | ||
[ModifiedDate] DATETIME CONSTRAINT [DF_Product_ModifiedDate] DEFAULT (getdate()) NOT NULL, | ||
CONSTRAINT [PK_Product_ProductID] PRIMARY KEY CLUSTERED ([ProductID] ASC), | ||
CONSTRAINT [CK_Product_ListPrice] CHECK ([ListPrice]>=(0.00)), | ||
CONSTRAINT [CK_Product_SellEndDate] CHECK ([SellEndDate]>=[SellStartDate] OR [SellEndDate] IS NULL), | ||
CONSTRAINT [CK_Product_StandardCost] CHECK ([StandardCost]>=(0.00)), | ||
CONSTRAINT [CK_Product_Weight] CHECK ([Weight]>(0.00)), | ||
CONSTRAINT [FK_Product_ProductCategory_ProductCategoryID] FOREIGN KEY ([ProductCategoryID]) REFERENCES [SalesLT].[ProductCategory] ([ProductCategoryID]), | ||
CONSTRAINT [FK_Product_ProductModel_ProductModelID] FOREIGN KEY ([ProductModelID]) REFERENCES [SalesLT].[ProductModel] ([ProductModelID]), | ||
CONSTRAINT [AK_Product_Name] UNIQUE NONCLUSTERED ([Name] ASC), | ||
CONSTRAINT [AK_Product_ProductNumber] UNIQUE NONCLUSTERED ([ProductNumber] ASC), | ||
CONSTRAINT [AK_Product_rowguid] UNIQUE NONCLUSTERED ([rowguid] ASC) | ||
); | ||
|
12 changes: 12 additions & 0 deletions
12
examples/sqlserver/src/sql-template/SalesLT/Tables/ProductCategory.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CREATE TABLE [SalesLT].[ProductCategory] ( | ||
[ProductCategoryID] INT IDENTITY (1, 1) NOT NULL, | ||
[ParentProductCategoryID] INT NULL, | ||
[Name] [dbo].[Name] NOT NULL, | ||
[rowguid] UNIQUEIDENTIFIER CONSTRAINT [DF_ProductCategory_rowguid] DEFAULT (newid()) NOT NULL, | ||
[ModifiedDate] DATETIME CONSTRAINT [DF_ProductCategory_ModifiedDate] DEFAULT (getdate()) NOT NULL, | ||
CONSTRAINT [PK_ProductCategory_ProductCategoryID] PRIMARY KEY CLUSTERED ([ProductCategoryID] ASC), | ||
CONSTRAINT [FK_ProductCategory_ProductCategory_ParentProductCategoryID_ProductCategoryID] FOREIGN KEY ([ParentProductCategoryID]) REFERENCES [SalesLT].[ProductCategory] ([ProductCategoryID]), | ||
CONSTRAINT [AK_ProductCategory_Name] UNIQUE NONCLUSTERED ([Name] ASC), | ||
CONSTRAINT [AK_ProductCategory_rowguid] UNIQUE NONCLUSTERED ([rowguid] ASC) | ||
); | ||
|
9 changes: 9 additions & 0 deletions
9
examples/sqlserver/src/sql-template/SalesLT/Tables/ProductDescription.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE [SalesLT].[ProductDescription] ( | ||
[ProductDescriptionID] INT IDENTITY (1, 1) NOT NULL, | ||
[Description] NVARCHAR (400) NOT NULL, | ||
[rowguid] UNIQUEIDENTIFIER CONSTRAINT [DF_ProductDescription_rowguid] DEFAULT (newid()) NOT NULL, | ||
[ModifiedDate] DATETIME CONSTRAINT [DF_ProductDescription_ModifiedDate] DEFAULT (getdate()) NOT NULL, | ||
CONSTRAINT [PK_ProductDescription_ProductDescriptionID] PRIMARY KEY CLUSTERED ([ProductDescriptionID] ASC), | ||
CONSTRAINT [AK_ProductDescription_rowguid] UNIQUE NONCLUSTERED ([rowguid] ASC) | ||
); | ||
|
11 changes: 11 additions & 0 deletions
11
examples/sqlserver/src/sql-template/SalesLT/Tables/ProductModel.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE TABLE [SalesLT].[ProductModel] ( | ||
[ProductModelID] INT IDENTITY (1, 1) NOT NULL, | ||
[Name] [dbo].[Name] NOT NULL, | ||
[CatalogDescription] XML NULL, | ||
[rowguid] UNIQUEIDENTIFIER CONSTRAINT [DF_ProductModel_rowguid] DEFAULT (newid()) NOT NULL, | ||
[ModifiedDate] DATETIME CONSTRAINT [DF_ProductModel_ModifiedDate] DEFAULT (getdate()) NOT NULL, | ||
CONSTRAINT [PK_ProductModel_ProductModelID] PRIMARY KEY CLUSTERED ([ProductModelID] ASC), | ||
CONSTRAINT [AK_ProductModel_Name] UNIQUE NONCLUSTERED ([Name] ASC), | ||
CONSTRAINT [AK_ProductModel_rowguid] UNIQUE NONCLUSTERED ([rowguid] ASC) | ||
); | ||
|
12 changes: 12 additions & 0 deletions
12
examples/sqlserver/src/sql-template/SalesLT/Tables/ProductModelProductDescription.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CREATE TABLE [SalesLT].[ProductModelProductDescription] ( | ||
[ProductModelID] INT NOT NULL, | ||
[ProductDescriptionID] INT NOT NULL, | ||
[Culture] NCHAR (6) NOT NULL, | ||
[rowguid] UNIQUEIDENTIFIER CONSTRAINT [DF_ProductModelProductDescription_rowguid] DEFAULT (newid()) NOT NULL, | ||
[ModifiedDate] DATETIME CONSTRAINT [DF_ProductModelProductDescription_ModifiedDate] DEFAULT (getdate()) NOT NULL, | ||
CONSTRAINT [PK_ProductModelProductDescription_ProductModelID_ProductDescriptionID_Culture] PRIMARY KEY CLUSTERED ([ProductModelID] ASC, [ProductDescriptionID] ASC, [Culture] ASC), | ||
CONSTRAINT [FK_ProductModelProductDescription_ProductDescription_ProductDescriptionID] FOREIGN KEY ([ProductDescriptionID]) REFERENCES [SalesLT].[ProductDescription] ([ProductDescriptionID]), | ||
CONSTRAINT [FK_ProductModelProductDescription_ProductModel_ProductModelID] FOREIGN KEY ([ProductModelID]) REFERENCES [SalesLT].[ProductModel] ([ProductModelID]), | ||
CONSTRAINT [AK_ProductModelProductDescription_rowguid] UNIQUE NONCLUSTERED ([rowguid] ASC) | ||
); | ||
|
24 changes: 24 additions & 0 deletions
24
examples/sqlserver/src/sql-template/SalesLT/Tables/SalesOrderDetail.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
CREATE TABLE [SalesLT].[SalesOrderDetail] ( | ||
[SalesOrderID] INT NOT NULL, | ||
[SalesOrderDetailID] INT IDENTITY (1, 1) NOT NULL, | ||
[OrderQty] SMALLINT NOT NULL, | ||
[ProductID] INT NOT NULL, | ||
[UnitPrice] MONEY NOT NULL, | ||
[UnitPriceDiscount] MONEY CONSTRAINT [DF_SalesOrderDetail_UnitPriceDiscount] DEFAULT ((0.0)) NOT NULL, | ||
[LineTotal] AS (isnull(([UnitPrice]*((1.0)-[UnitPriceDiscount]))*[OrderQty],(0.0))), | ||
[rowguid] UNIQUEIDENTIFIER CONSTRAINT [DF_SalesOrderDetail_rowguid] DEFAULT (newid()) NOT NULL, | ||
[ModifiedDate] DATETIME CONSTRAINT [DF_SalesOrderDetail_ModifiedDate] DEFAULT (getdate()) NOT NULL, | ||
CONSTRAINT [PK_SalesOrderDetail_SalesOrderID_SalesOrderDetailID] PRIMARY KEY CLUSTERED ([SalesOrderID] ASC, [SalesOrderDetailID] ASC), | ||
CONSTRAINT [CK_SalesOrderDetail_OrderQty] CHECK ([OrderQty]>(0)), | ||
CONSTRAINT [CK_SalesOrderDetail_UnitPrice] CHECK ([UnitPrice]>=(0.00)), | ||
CONSTRAINT [CK_SalesOrderDetail_UnitPriceDiscount] CHECK ([UnitPriceDiscount]>=(0.00)), | ||
CONSTRAINT [FK_SalesOrderDetail_Product_ProductID] FOREIGN KEY ([ProductID]) REFERENCES [SalesLT].[Product] ([ProductID]), | ||
CONSTRAINT [FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID] FOREIGN KEY ([SalesOrderID]) REFERENCES [SalesLT].[SalesOrderHeader] ([SalesOrderID]) ON DELETE CASCADE, | ||
CONSTRAINT [AK_SalesOrderDetail_rowguid] UNIQUE NONCLUSTERED ([rowguid] ASC) | ||
); | ||
|
||
|
||
GO | ||
CREATE NONCLUSTERED INDEX [IX_SalesOrderDetail_ProductID] | ||
ON [SalesLT].[SalesOrderDetail]([ProductID] ASC); | ||
|
42 changes: 42 additions & 0 deletions
42
examples/sqlserver/src/sql-template/SalesLT/Tables/SalesOrderHeader.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
CREATE TABLE [SalesLT].[SalesOrderHeader] ( | ||
[SalesOrderID] INT CONSTRAINT [DF_SalesOrderHeader_OrderID] DEFAULT (NEXT VALUE FOR [SalesLT].[SalesOrderNumber]) NOT NULL, | ||
[RevisionNumber] TINYINT CONSTRAINT [DF_SalesOrderHeader_RevisionNumber] DEFAULT ((0)) NOT NULL, | ||
[OrderDate] DATETIME CONSTRAINT [DF_SalesOrderHeader_OrderDate] DEFAULT (getdate()) NOT NULL, | ||
[DueDate] DATETIME NOT NULL, | ||
[ShipDate] DATETIME NULL, | ||
[Status] TINYINT CONSTRAINT [DF_SalesOrderHeader_Status] DEFAULT ((1)) NOT NULL, | ||
[OnlineOrderFlag] [dbo].[Flag] CONSTRAINT [DF_SalesOrderHeader_OnlineOrderFlag] DEFAULT ((1)) NOT NULL, | ||
[SalesOrderNumber] AS (isnull(N'SO'+CONVERT([nvarchar](23),[SalesOrderID],(0)),N'*** ERROR ***')), | ||
[PurchaseOrderNumber] [dbo].[OrderNumber] NULL, | ||
[AccountNumber] [dbo].[AccountNumber] NULL, | ||
[CustomerID] INT NOT NULL, | ||
[ShipToAddressID] INT NULL, | ||
[BillToAddressID] INT NULL, | ||
[ShipMethod] NVARCHAR (50) NOT NULL, | ||
[CreditCardApprovalCode] VARCHAR (15) NULL, | ||
[SubTotal] MONEY CONSTRAINT [DF_SalesOrderHeader_SubTotal] DEFAULT ((0.00)) NOT NULL, | ||
[TaxAmt] MONEY CONSTRAINT [DF_SalesOrderHeader_TaxAmt] DEFAULT ((0.00)) NOT NULL, | ||
[Freight] MONEY CONSTRAINT [DF_SalesOrderHeader_Freight] DEFAULT ((0.00)) NOT NULL, | ||
[TotalDue] AS (isnull(([SubTotal]+[TaxAmt])+[Freight],(0))), | ||
[Comment] NVARCHAR (MAX) NULL, | ||
[rowguid] UNIQUEIDENTIFIER CONSTRAINT [DF_SalesOrderHeader_rowguid] DEFAULT (newid()) NOT NULL, | ||
[ModifiedDate] DATETIME CONSTRAINT [DF_SalesOrderHeader_ModifiedDate] DEFAULT (getdate()) NOT NULL, | ||
CONSTRAINT [PK_SalesOrderHeader_SalesOrderID] PRIMARY KEY CLUSTERED ([SalesOrderID] ASC), | ||
CONSTRAINT [CK_SalesOrderHeader_DueDate] CHECK ([DueDate]>=[OrderDate]), | ||
CONSTRAINT [CK_SalesOrderHeader_Freight] CHECK ([Freight]>=(0.00)), | ||
CONSTRAINT [CK_SalesOrderHeader_ShipDate] CHECK ([ShipDate]>=[OrderDate] OR [ShipDate] IS NULL), | ||
CONSTRAINT [CK_SalesOrderHeader_Status] CHECK ([Status]>=(0) AND [Status]<=(8)), | ||
CONSTRAINT [CK_SalesOrderHeader_SubTotal] CHECK ([SubTotal]>=(0.00)), | ||
CONSTRAINT [CK_SalesOrderHeader_TaxAmt] CHECK ([TaxAmt]>=(0.00)), | ||
CONSTRAINT [FK_SalesOrderHeader_Address_BillTo_AddressID] FOREIGN KEY ([BillToAddressID]) REFERENCES [SalesLT].[Address] ([AddressID]), | ||
CONSTRAINT [FK_SalesOrderHeader_Address_ShipTo_AddressID] FOREIGN KEY ([ShipToAddressID]) REFERENCES [SalesLT].[Address] ([AddressID]), | ||
CONSTRAINT [FK_SalesOrderHeader_Customer_CustomerID] FOREIGN KEY ([CustomerID]) REFERENCES [SalesLT].[Customer] ([CustomerID]), | ||
CONSTRAINT [AK_SalesOrderHeader_rowguid] UNIQUE NONCLUSTERED ([rowguid] ASC), | ||
CONSTRAINT [AK_SalesOrderHeader_SalesOrderNumber] UNIQUE NONCLUSTERED ([SalesOrderNumber] ASC) | ||
); | ||
|
||
|
||
GO | ||
CREATE NONCLUSTERED INDEX [IX_SalesOrderHeader_CustomerID] | ||
ON [SalesLT].[SalesOrderHeader]([CustomerID] ASC); | ||
|
21 changes: 21 additions & 0 deletions
21
examples/sqlserver/src/sql-template/SalesLT/Views/vGetAllCategories.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
CREATE VIEW [SalesLT].[vGetAllCategories] | ||
WITH SCHEMABINDING | ||
AS | ||
-- Returns the CustomerID, first name, and last name for the specified customer. | ||
WITH CategoryCTE([ParentProductCategoryID], [ProductCategoryID], [Name]) AS | ||
( | ||
SELECT [ParentProductCategoryID], [ProductCategoryID], [Name] | ||
FROM SalesLT.ProductCategory | ||
WHERE ParentProductCategoryID IS NULL | ||
|
||
UNION ALL | ||
|
||
SELECT C.[ParentProductCategoryID], C.[ProductCategoryID], C.[Name] | ||
FROM SalesLT.ProductCategory AS C | ||
INNER JOIN CategoryCTE AS BC ON BC.ProductCategoryID = C.ParentProductCategoryID | ||
) | ||
|
||
SELECT PC.[Name] AS [ParentProductCategoryName], CCTE.[Name] as [ProductCategoryName], CCTE.[ProductCategoryID] | ||
FROM CategoryCTE AS CCTE | ||
JOIN SalesLT.ProductCategory AS PC | ||
ON PC.[ProductCategoryID] = CCTE.[ParentProductCategoryID] |
22 changes: 22 additions & 0 deletions
22
examples/sqlserver/src/sql-template/SalesLT/Views/vProductAndDescription.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
CREATE VIEW [SalesLT].[vProductAndDescription] | ||
WITH SCHEMABINDING | ||
AS | ||
-- View (indexed or standard) to display products and product descriptions by language. | ||
SELECT | ||
p.[ProductID] | ||
,p.[Name] | ||
,pm.[Name] AS [ProductModel] | ||
,pmx.[Culture] | ||
,pd.[Description] | ||
FROM [SalesLT].[Product] p | ||
INNER JOIN [SalesLT].[ProductModel] pm | ||
ON p.[ProductModelID] = pm.[ProductModelID] | ||
INNER JOIN [SalesLT].[ProductModelProductDescription] pmx | ||
ON pm.[ProductModelID] = pmx.[ProductModelID] | ||
INNER JOIN [SalesLT].[ProductDescription] pd | ||
ON pmx.[ProductDescriptionID] = pd.[ProductDescriptionID]; | ||
|
||
GO | ||
CREATE UNIQUE CLUSTERED INDEX [IX_vProductAndDescription] | ||
ON [SalesLT].[vProductAndDescription]([Culture] ASC, [ProductID] ASC); | ||
|
Oops, something went wrong.