📜  将 SQL Server 中的数据提取为 XML 格式 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:21.079000             🧑  作者: Mango

代码示例1
--SQL Code extract to XML format w/ more explicite and well formed tags than just using "For XML Auto"
    SELECT 
        [EmployeeID] AS '@ID',
        [LastName], [FirstName],
        [Title],
        [BirthDate], [HireDate]
    FROM 
        [dbo].[Employees]
    FOR XML PATH('Employee'), ROOT('Employees')


--Output of This SQL below
    
      
        Davolio
        Nancy
        Sales Representative
        1948-12-08T00:00:00
        1992-05-01T00:00:00
      
      
        Fuller
        Andrew
        Vice President, Sales
        1952-02-19T00:00:00
        1992-08-14T00:00:00