I have a table which has XMLData column as TEXT. How can i read the data from this column
As long as that column is of type TEXT, you won't be able to do anything useful with it, really. TEXT also has been deprecated and will be removed in a future version of SQL Server - stop using it.
If it stores XML and only XML - make it of datatype XML.
One you have that, you can either extract individual items of information from that XML using XPath and XQuery - something like:
SELECT
YourXMlColumn.value('(/Root/SomeItems/Item/FirstName)[1]', 'varchar(50)') as 'FirstName',
YourXMlColumn.value('(/Root/SomeItems/Item/Age)[1]', 'int') as 'Age'
FROM
dbo.YourTable
WHERE
(some condition)
or if you have multiple items in a list-like structure inside your XML, you can create a "pseudo-table" of XML items based on an XPath expression.
So your plan of action should be:
XMLIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With