开放式XML:
DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc =
'<ROOT>
<Employee EmployeeID = "1" EmpStatus = "Full Time"/>
<Employee EmployeeID = "2" EmpStatus ="Part Time" />
</ROOT>'
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
SELECT *
FROM OPENXML (@idoc, '/ROOT/Employee',1)
WITH (EmployeeID varchar(10),
EmpStatus varchar(20))
结果:
EmployeeID EmpStatus
1 Full Time
2 Part Time
表查询:
SELECT hr.EmployeeID, hr.Title, c.FirstName,c.LastName
FROM HumanResources.Employee hr WITH (NOLOCK)
INNER JOIN ContactInfo c WITH (NOLOCK)
ON hr.ContactID = c.ContactID
Where hr. EmployeeID IN ( 1, 2)
结果:
EmployeeID Title FirstName LastName
1 Engineering Mike Brown
2 Programmer Yves Anthony
如何将 OpenXML 数据加入到我的内部连接查询中EmployeeID
?