forked from grrlgeek/extended-events
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWorkload Wait Statistics.sql
More file actions
43 lines (36 loc) · 1.28 KB
/
Copy pathWorkload Wait Statistics.sql
File metadata and controls
43 lines (36 loc) · 1.28 KB
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
/* Workload for Wait Statistics */
USE AdventureWorks2014;
GO
--Read
SELECT P.ProductNumber, P.Name, PS.Name AS SubcategoryName, PC.Name AS CategoryName
FROM Production.Product P
INNER JOIN Production.ProductSubcategory PS ON PS.ProductSubcategoryID = P.ProductSubcategoryID
INNER JOIN Production.ProductCategory PC ON PC.ProductCategoryID = PS.ProductCategoryID
--Write
CREATE TABLE TestForWaitStats
(ID INT IDENTITY,
Superhero VARCHAR(25),
PlanetOfOrigin VARCHAR(25));
INSERT INTO TestForWaitStats
VALUES ('Wonder Woman', 'Paradise Island'), ('Superman', 'Krypton'), ('Batman', 'Earth');
DELETE FROM TestForWaitStats
WHERE Superhero = 'Batman';
--tempdb
CREATE TABLE #BigTempTable
(Value INT);
DECLARE @Number INT = 1;
WHILE @Number < 1000
BEGIN
INSERT INTO #BigTempTable VALUES (@Number);
SET @Number = @Number + 1
END
SELECT *
FROM #BigTempTable;
--More
SELECT P.FirstName + ' ' + P.LastName AS SalesPerson, SP.SalesQuota, SP.SalesYTD, SP.SalesLastYear, SP.SalesYTD - SP.SalesLastYear AS YearDiff, SP.Bonus, ST.Name AS Territory
FROM Sales.SalesPerson SP
INNER JOIN Person.Person P ON P.BusinessEntityID = SP.BusinessEntityID
INNER JOIN Sales.SalesTerritory ST ON ST.TerritoryID = SP.TerritoryID;
--Cleanup
DROP TABLE TestForWaitStats;
DROP TABLE #BigTempTable;