我面临一个关于 xml 输出的小问题。
这是我的程序,它将根据输入列出所有员工及其一些个人信息。
CREATE PROC getDeptEmployees(@deptList varchar(500))
AS
BEGIN
SET NOCOUNT ON
DECLARE @Query varchar(600)
SET @Query = '
SELECT department.DEPARTMENT_ID [f_Department_ID], department.DEPARTMENT_NAME [f_Department_name],
dp.Employee_id [f_Employee_ID], dp.First_name [f_First_Name],
dp.Last_Name [f_Last_name], dp.Email [f_email], dp.Salary [f_salary]
FROM dbo.Employees dp
JOIN DEPARTMENTS department
ON dp.DEPARTMENT_ID = department.DEPARTMENT_ID
WHERE dp.Department_id IN (' + @deptList + ')
for XML AUTO, ROOT(''table'')'
EXEC(@Query)
END
GO
我得到的是这里, 但我仍然不知道如何添加 DPR 节点。
谢谢