I am currently trying to get better on AdventureWorks but I've got one issue. Indeed, I would like to use the data from the column "Demographics" on the table Sales_Store but I don't know how I can separate the different elements. Example of one record below:
\<StoreSurvey xmlns="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/StoreSurvey"\>
\<AnnualSales\>800000\</AnnualSales\>
\<AnnualRevenue\>80000\</AnnualRevenue\>
\<BankName\>United Security\</BankName\>
\<BusinessType\>BM\</BusinessType\>
\<YearOpened\>1996\</YearOpened\>
\<Specialty\>Mountain\</Specialty\>
\<SquareFeet\>21000\</SquareFeet\>
\<Brands\>2\</Brands\>
\<Internet\>ISDN\</Internet\>
\<NumberEmployees\>13\</NumberEmployees\>
\</StoreSurvey\>
I am working with access but i can also use MySQL.
I already use the the function Split but i don't know why it did not work at all.
SELECT
Split(Split(Demographics, '<')(1), '>')(0) AS AnnualSales,
Split(Split(Demographics, '<AnnualRevenue>')(1), '</AnnualRevenue>')(0) AS AnnualRevenue,
Split(Split(Demographics, '<BankName>')(1), '</BankName>')(0) AS BankName,
Split(Split(Demographics, '<BusinessType>')(1), '</BusinessType>')(0) AS BusinessType,
Split(Split(Demographics, '<YearOpened>')(1), '</YearOpened>')(0) AS YearOpened,
Split(Split(Demographics, '<Specialty>')(1), '</Specialty>')(0) AS Specialty,
Split(Split(Demographics, '<SquareFeet>')(1), '</SquareFeet>')(0) AS SquareFeet,
Split(Split(Demographics, '<Brands>')(1), '</Brands>')(0) AS Brands,
Split(Split(Demographics, '<Internet>')(1), '</Internet>')(0) AS Internet,
Split(Split(Demographics, '<NumberEmployees>')(1), '</NumberEmployees>')(0) AS NumberEmployees
FROM
Sales_Store
SELECT
ExtractValue(Demographics, 'StoreSurvey/AnnualSales') AS AnnualSales,
ExtractValue(Demographics, 'StoreSurvey/AnnualRevenue') AS AnnualRevenue,
ExtractValue(Demographics, 'StoreSurvey/BankName') AS BankName,
ExtractValue(Demographics, 'StoreSurvey/BusinessType') AS BusinessType,
ExtractValue(Demographics, 'StoreSurvey/YearOpened') AS YearOpened,
ExtractValue(Demographics, 'StoreSurvey/Specialty') AS Specialty,
ExtractValue(Demographics, 'StoreSurvey/SquareFeet') AS SquareFeet,
ExtractValue(Demographics, 'StoreSurvey/Brands') AS Brands,
ExtractValue(Demographics, 'StoreSurvey/Internet') AS Internet,
ExtractValue(Demographics, 'StoreSurvey/NumberEmployees') AS NumberEmployees
FROM
Sales_Store
The link for the database is right there https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2016.bak