HResult 0x2, Level 16, State 1
Named Pipes Privider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default setting SQL Server does not allow remote connections..
Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.
USE AdventureWorks;
GO
SELECT c.FirstName + ' ' + c.LastName AS 'Employee Name',
a.AddressLine1, a.AddressLine2 , a.City, a.PostalCode
FROM Person.Contact AS c
INNER JOIN HumanResources.Employee AS e
ON c.ContactID = e.ContactID
INNER JOIN HumanResources.EmployeeAddress ea
ON ea.EmployeeID = e.EmployeeID
INNER JOIN Person.Address AS a
ON a.AddressID = ea.AddressID;
GO
SELECT fields
FROM table1 INNER JOIN table2
ON table1.field1 compopr table2.field1 AND
ON table1.field2 compopr table2.field2) OR
ON table1.field3 compopr table2.field3)];
也可以通过如下语法嵌套 JOIN 语句:
SELECT fields
FROM table1 INNER JOIN (table2 INNER JOIN [( ]table3[INNER JOIN [( ]tablex [INNER JOIN ...)]
ON table3.field3 compopr tablex.fieldx)]
ON table2.field2 compopr table3.field3) ON table1.field1 compopr table2.field2;
LEFT JOIN 或 RIGHT JOIN 可以嵌套在 INNER JOIN 之中,但是 INNER JOIN 不能嵌套于 LEFT JOIN 或 RIGHT JOIN 之中。