53 lines
1.4 KiB
Plaintext
53 lines
1.4 KiB
Plaintext
|
CREATE TABLE dbo.EmployeePhoto
|
||
|
(
|
||
|
EmployeeId INT NOT NULL PRIMARY KEY,
|
||
|
Photo VARBINARY(MAX) FILESTREAM NULL,
|
||
|
MyRowGuidColumn UNIQUEIDENTIFIER NOT NULL ROWGUIDCOL
|
||
|
UNIQUE DEFAULT NEWID()
|
||
|
);
|
||
|
|
||
|
GO
|
||
|
|
||
|
/*
|
||
|
text_of_comment
|
||
|
/* nested comment */
|
||
|
*/
|
||
|
|
||
|
-- line comment
|
||
|
|
||
|
CREATE NONCLUSTERED INDEX IX_WorkOrder_ProductID
|
||
|
ON Production.WorkOrder(ProductID)
|
||
|
WITH (FILLFACTOR = 80,
|
||
|
PAD_INDEX = ON,
|
||
|
DROP_EXISTING = ON);
|
||
|
GO
|
||
|
|
||
|
WHILE (SELECT AVG(ListPrice) FROM Production.Product) < $300
|
||
|
BEGIN
|
||
|
UPDATE Production.Product
|
||
|
SET ListPrice = ListPrice * 2
|
||
|
SELECT MAX(ListPrice) FROM Production.Product
|
||
|
IF (SELECT MAX(ListPrice) FROM Production.Product) > $500
|
||
|
BREAK
|
||
|
ELSE
|
||
|
CONTINUE
|
||
|
END
|
||
|
PRINT 'Too much for the market to bear';
|
||
|
|
||
|
MERGE INTO Sales.SalesReason AS [Target]
|
||
|
USING (VALUES ('Recommendation','Other'), ('Review', 'Marketing'), ('Internet', 'Promotion'))
|
||
|
AS [Source] ([NewName], NewReasonType)
|
||
|
ON [Target].[Name] = [Source].[NewName]
|
||
|
WHEN MATCHED
|
||
|
THEN UPDATE SET ReasonType = [Source].NewReasonType
|
||
|
WHEN NOT MATCHED BY TARGET
|
||
|
THEN INSERT ([Name], ReasonType) VALUES ([NewName], NewReasonType)
|
||
|
OUTPUT $action INTO @SummaryOfChanges;
|
||
|
|
||
|
SELECT ProductID, OrderQty, SUM(LineTotal) AS Total
|
||
|
FROM Sales.SalesOrderDetail
|
||
|
WHERE UnitPrice < $5.00
|
||
|
GROUP BY ProductID, OrderQty
|
||
|
ORDER BY ProductID, OrderQty
|
||
|
OPTION (HASH GROUP, FAST 10);
|