General SQL Parser and SQL Pretty Printer Formatter options
Index
Available format options for subquery:
Example format options:
Formatted SQL:
SELECT [Northwind].[dbo].[Order Details].[Discount],
[Northwind].[dbo].[Order Details].[OrderID] AS [OrderId],
[Northwind].[dbo].[Order Details].[ProductID] AS [ProductId],
[Northwind].[dbo].[Order Details].[Quantity],
[Northwind].[dbo].[Order Details].[UnitPrice]
FROM [Northwind].[dbo].[Order Details]
WHERE ( [Northwind].[dbo].[Order Details].[OrderID] IN (SELECT [Northwind].[dbo].[Orders].[OrderID] AS [OrderId]
FROM [Northwind].[dbo].[Orders]
WHERE (( [Northwind].[dbo].[Orders].[CustomerID] IN (SELECT [Northwind].[dbo].[Customers].[CustomerID] AS [CustomerId]
FROM [Northwind].[dbo].[Customers]) ))) )
Formatted SQL: the following query is not so wide as previous one.
SELECT [Northwind].[dbo].[Order Details].[Discount],
[Northwind].[dbo].[Order Details].[OrderID] AS [OrderId],
[Northwind].[dbo].[Order Details].[ProductID] AS [ProductId],
[Northwind].[dbo].[Order Details].[Quantity],
[Northwind].[dbo].[Order Details].[UnitPrice]
FROM [Northwind].[dbo].[Order Details]
WHERE ( [Northwind].[dbo].[Order Details].[OrderID] IN
(SELECT [Northwind].[dbo].[Orders].[OrderID] AS [OrderId]
FROM [Northwind].[dbo].[Orders]
WHERE (( [Northwind].[dbo].[Orders].[CustomerID] IN
(SELECT [Northwind].[dbo].[Customers].[CustomerID] AS [CustomerId]
FROM [Northwind].[dbo].[Customers]) ))) )
Example format options:
Formatted SQL:
SELECT TOP 1 CASE
WHEN CASE
WHEN NOT EXISTS (SELECT [LPA_L1].[CategoryId]
FROM (SELECT [Northwind].[dbo].[Products].[CategoryID] AS [CategoryId],
[Northwind].[dbo].[Products].[Discontinued],
[Northwind].[dbo].[Products].[ProductID] AS [ProductId],
[Northwind].[dbo].[Products].[ProductName],
[Northwind].[dbo].[Products].[QuantityPerUnit],
[Northwind].[dbo].[Products].[ReorderLevel],
[Northwind].[dbo].[Products].[SupplierID] AS [SupplierId],
[Northwind].[dbo].[Products].[UnitPrice],
[Northwind].[dbo].[Products].[UnitsInStock],
[Northwind].[dbo].[Products].[UnitsOnOrder]
FROM [Northwind].[dbo].[Products]
WHERE (( [Northwind].[dbo].[Products].[CategoryID] = @p1 ))) [LPA_L1]) THEN 1
ELSE 0
END = 1 THEN @p3
ELSE @p5
END AS [LLBLV_1]
FROM [Northwind].[dbo].[Products];
Formatted SQL: the following query is not so wide as previous one.
SELECT TOP 1 CASE
WHEN CASE
WHEN NOT EXISTS
(SELECT [LPA_L1].[CategoryId]
FROM (SELECT [Northwind].[dbo].[Products].[CategoryID] AS [CategoryId],
[Northwind].[dbo].[Products].[Discontinued],
[Northwind].[dbo].[Products].[ProductID] AS [ProductId],
[Northwind].[dbo].[Products].[ProductName],
[Northwind].[dbo].[Products].[QuantityPerUnit],
[Northwind].[dbo].[Products].[ReorderLevel],
[Northwind].[dbo].[Products].[SupplierID] AS [SupplierId],
[Northwind].[dbo].[Products].[UnitPrice],
[Northwind].[dbo].[Products].[UnitsInStock],
[Northwind].[dbo].[Products].[UnitsOnOrder]
FROM [Northwind].[dbo].[Products]
WHERE (( [Northwind].[dbo].[Products].[CategoryID] = @p1 ))) [LPA_L1]) THEN 1
ELSE 0
END = 1 THEN @p3
ELSE @p5
END AS [LLBLV_1]
FROM [Northwind].[dbo].[Products];
Example format options:
Formatted SQL:
SELECT *
FROM t
WHERE SomeField = (SELECT TOP 1 Blah
FROM t1
ORDER BY f)
Formatted SQL: the following query is not so wide as previous one.
SELECT *
FROM t
WHERE SomeField =
(SELECT TOP 1 Blah
FROM t1
ORDER BY f)
Example format options:
Formatted SQL:
SELECT [Northwind].[dbo].[Categories].[CategoryID] AS [CategoryId],
[Northwind].[dbo].[Categories].[CategoryName],
[Northwind].[dbo].[Categories].[Description],
[Northwind].[dbo].[Categories].[Picture]
FROM [Northwind].[dbo].[Categories]
WHERE (((( (SELECT Sum([LPA_L1].[UnitsInStock]) AS [LPAV_]
FROM (SELECT [Northwind].[dbo].[Products].[CategoryID] AS [CategoryId],
[Northwind].[dbo].[Products].[Discontinued],
[Northwind].[dbo].[Products].[ProductID] AS [ProductId],
[Northwind].[dbo].[Products].[ProductName],
[Northwind].[dbo].[Products].[QuantityPerUnit],
[Northwind].[dbo].[Products].[ReorderLevel],
[Northwind].[dbo].[Products].[SupplierID] AS [SupplierId],
[Northwind].[dbo].[Products].[UnitPrice],
[Northwind].[dbo].[Products].[UnitsInStock],
[Northwind].[dbo].[Products].[UnitsOnOrder]
FROM [Northwind].[dbo].[Products]
WHERE (( [Products].[CategoryID] = [Categories].[CategoryID] ))) [LPA_L1]) > @p2 ))))
Formatted SQL: have the '> @p2' on another line so
it's easier to see that the left operand is the complete scalar and it
doesn't secretly belong to the WHERE of the scalar.
SELECT [Northwind].[dbo].[Categories].[CategoryID] AS [CategoryId],
[Northwind].[dbo].[Categories].[CategoryName],
[Northwind].[dbo].[Categories].[Description],
[Northwind].[dbo].[Categories].[Picture]
FROM [Northwind].[dbo].[Categories]
WHERE (((( (SELECT Sum([LPA_L1].[UnitsInStock]) AS [LPAV_]
FROM (SELECT [Northwind].[dbo].[Products].[CategoryID] AS [CategoryId],
[Northwind].[dbo].[Products].[Discontinued],
[Northwind].[dbo].[Products].[ProductID] AS [ProductId],
[Northwind].[dbo].[Products].[ProductName],
[Northwind].[dbo].[Products].[QuantityPerUnit],
[Northwind].[dbo].[Products].[ReorderLevel],
[Northwind].[dbo].[Products].[SupplierID] AS [SupplierId],
[Northwind].[dbo].[Products].[UnitPrice],
[Northwind].[dbo].[Products].[UnitsInStock],
[Northwind].[dbo].[Products].[UnitsOnOrder]
FROM [Northwind].[dbo].[Products]
WHERE (( [Products].[CategoryID] = [Categories].[CategoryID] ))) [LPA_L1])
> @p2 ))))