Home
/
Beautifiers
/
SQL Formatter
Enter Unformatted sql
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 commentCREATE NONCLUSTERED INDEX IX_WorkOrder_ProductID ON Production.WorkOrder(ProductID) WITH (FILLFACTOR = 80, PAD_INDEX = ON, DROP_EXISTING = ON);GOWHILE (SELECT AVG(ListPrice) FROM Production.Product) < $300BEGIN UPDATE Production.Product SET ListPrice = ListPrice * 2 SELECT MAX(ListPrice) FROM Production.Product IF (SELECT MAX(ListPrice) FROM Production.Product) > $500 BREAK ELSE CONTINUEENDPRINT '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 MATCHEDTHEN UPDATE SET ReasonType = [Source].NewReasonTypeWHEN NOT MATCHED BY TARGETTHEN INSERT ([Name], ReasonType) VALUES ([NewName], NewReasonType)OUTPUT $action INTO @SummaryOfChanges;SELECT ProductID, OrderQty, SUM(LineTotal) AS TotalFROM Sales.SalesOrderDetailWHERE UnitPrice < $5.00GROUP BY ProductID, OrderQtyORDER BY ProductID, OrderQtyOPTION (HASH GROUP, FAST 10);
Formatted sql