Skip to content

Instantly share code, notes, and snippets.

@sqlparser
Created April 8, 2014 02:46
Show Gist options
  • Save sqlparser/10085055 to your computer and use it in GitHub Desktop.
Save sqlparser/10085055 to your computer and use it in GitHub Desktop.
Insert subquery indent
INSERT TOP (10) INTO HumanResources.NewEmployee
SELECT
e.BusinessEntityID, c.LastName, c.FirstName, pp.PhoneNumber,
a.AddressLine1, a.City, sp.StateProvinceCode,
a.PostalCode, e.CurrentFlag
FROM HumanResources.Employee e
INNER JOIN Person.BusinessEntityAddress AS bea
ON e.BusinessEntityID = bea.BusinessEntityID
INNER JOIN Person.Address AS a
ON bea.AddressID = a.AddressID
INNER JOIN Person.PersonPhone AS pp
ON e.BusinessEntityID = pp.BusinessEntityID
INNER JOIN Person.StateProvince AS sp
ON a.StateProvinceID = sp.StateProvinceID
INNER JOIN Person.Person as c
ON e.BusinessEntityID = c.BusinessEntityID;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment