在Sql Server中使用令人费解的xml选择语法

时间:2013-05-10 18:12:34

标签: sql-server xml

在下面的sql代码中,T(C)是什么意思?什么是T,什么是C?

declare @employeeData xml --this would be your XML input parameter
set @employeeData = '<employeeData>
<employee LastName="Smith" FirstName="Randolph" EmployeeID="1234567"/>
</employeeData>'

declare @xmlTable table (LastName nvarchar(255), FirstName nvarchar(255), EmployeeID int)

insert into @xmlTable (LastName, FirstName, EmployeeID)
select 
C.value('@LastName','nvarchar(255)') as LastName,
C.value('@FirstName','nvarchar(255)') as FirstName,
C.value('@EmployeeID','int') as EmployeeID
from
@employeeData.nodes('/employeeData/employee') T(C)

select * from @xmlTable

1 个答案:

答案 0 :(得分:2)