Created
February 24, 2021 02:04
-
-
Save RickyLin/8c2e31595356d6bd7c59aba7043e6abd to your computer and use it in GitHub Desktop.
Extract values from XML type in SQL Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @Data XML | |
SET @Data = '<Ids> | |
<Id>64122</Id> | |
<Id>12345</Id> | |
<Id>67890</Id> | |
</Ids>' | |
SELECT Ids.Id.value('text()[1]', 'varchar(100)') | |
FROM @Data.nodes('Ids/Id') AS Ids(Id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment