DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS   SQL 2014 PROGRAMMING   DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to format and beautify T-SQL code?

SQL Format formats an beautifies T-SQL source code. In the input window you paste the T-SQL code like following:

USE AdventureWorks;
GO
WITH cteVendorPO
AS
(
SELECT PurchaseOrderID,
Employee=FirstName+' '+LastName,
Vendor = v.Name
FROM Purchasing.PurchaseOrderHeader poh
JOIN HumanResources.Employee e
ON poh.EmployeeID = e.EmployeeID
JOIN Person.Contact c
ON e.ContactID = c.ContactID
JOIN Purchasing.Vendor v
ON v.VendorID = poh.VendorID
)
SELECT *
FROM cteVendorPO v
PIVOT
(
COUNT (PurchaseOrderID)
FOR Employee IN
( [Erin Hagens], [Linda Meisner], [Sheela Word], [Frank Pellow], [Reinout Hillmann] )
) AS pvt
ORDER BY pvt.Vendor

In the result window it is returned formatted and beautified. This is how it looks after copy and paste to Management Studio Query Editor:

USE AdventureWorks;

 

GO

 

WITH cteVendorPO

     AS (SELECT PurchaseOrderID,

                Employee = FirstName + ' ' + LastName,

                Vendor = v.Name

         FROM   Purchasing.PurchaseOrderHeader poh

                JOIN HumanResources.Employee e

                  ON poh.EmployeeID = e.EmployeeID

                JOIN Person.Contact c

                  ON e.ContactID = c.ContactID

                JOIN Purchasing.Vendor v

                  ON v.VendorID = poh.VendorID)

SELECT   *

FROM     cteVendorPO v

         PIVOT

         (Count(PurchaseOrderID)

          FOR Employee IN ( [Erin Hagens],[Linda Meisner],[Sheela Word],[Frank Pellow],[Reinout Hillmann] ) ) AS pvt

ORDER BY pvt.Vendor

Click Here to Link to SQL Format

 


Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE