Advertisement
JanuszKowalski123

11. for xml

May 9th, 2024 (edited)
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. W tym zapytaniu użyłem funkcji CONVERT(NVARCHAR(MAX), ...), aby rzutować kolumny device_location, device_location_geom i device_hierarchy na typ NVARCHAR, który jest obsługiwany w zapytaniach FOR XML.
  2.  
  3. SELECT
  4. device_id AS [Device/@ID],
  5. device_status AS [Device/Status],
  6. device_power AS [Device/Power],
  7. company_id AS [Device/CompanyID],
  8. CONVERT(NVARCHAR(MAX), device_location) AS [Device/Location],
  9. CONVERT(NVARCHAR(MAX), device_location_geom) AS [Device/LocationGeom],
  10. CONVERT(NVARCHAR(MAX), device_hierarchy) AS [Device/Hierarchy],
  11. device_description AS [Device/Description]
  12. FROM
  13. Renewable_Energy_Devices
  14. FOR XML PATH('Device'), ROOT('Devices');
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement