/
create-workload-on-adventureworks.sql
64 lines (50 loc) · 1.21 KB
/
create-workload-on-adventureworks.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
USE [AdventureWorks2008R2]
GO
SET NOCOUNT ON
-- EXECUTE [dbo].[uspGetBillOfMaterials] MULTIPLE TIMES
DECLARE @ProductList table
(
[RowID] int IDENTITY(1,1),
[ProductID] int NOT NULL,
[CheckDate] datetime NULL
)
INSERT INTO @ProductList ([ProductID], [CheckDate])
SELECT TOP 200 p.[ProductID], b.[StartDate]
FROM [Production].[Product] AS p
LEFT JOIN [Production].[BillOfMaterials] AS b ON p.[ProductID] = b.[ComponentID]
ORDER BY [ProductID]
DECLARE @Counter int
DECLARE @RowNumber int
DECLARE @ProductID int
DECLARE @CheckDate datetime
SELECT @Counter = COUNT(*) FROM @ProductList
SET @RowNumber = 1
WHILE @Counter > 0
BEGIN
SELECT @ProductID = [ProductID],
@CheckDate = [CheckDate]
FROM @ProductList
WHERE [RowID] = @RowNumber
EXEC [dbo].[uspGetBillOfMaterials]
@StartProductID = @ProductID,
@CheckDate = @CheckDate
SET @RowNumber = @RowNumber + 1
SET @Counter = @Counter - 1
END
GO
-- SELECT FROM TABLES MULTIPLE TIMES
SELECT *
FROM [Sales].[Store]
GO 35
SELECT *
FROM [Sales].[SalesOrderHeader]
GO 35
SELECT *
FROM [Purchasing].[PurchaseOrderDetail]
GO 35
SELECT *
FROM [Sales].[Customer]
GO 35
SELECT *
FROM [Person].[Person]
GO 35