Reputation: 13467
I have table with a XML field that has specific constant format.How I can create a View based on this field that show me data in this field?
thanks
My Data is like this:
Upvotes: 0
Views: 2192
Reputation: 47058
You can create something like this
CREATE VIEW [dbo].[vEmployees]
WITH SCHEMABINDING
AS
SELECT
person.n.value('ID[1]', 'int') AS ID,
person.n.value('Name[1]', 'nvarchar(50)') AS Name,
person.n.value('LastName[1]', 'navarchar(50)') AS LastName
FROM dbo.Table x
CROSS APPLY x.XmlColumn.nodes('/Employees/Person') person(n)
GO
Upvotes: 0
Reputation: 138990
It is the same as creating any view.
create view vName
as
select somecolumn
from sometable
Just insert your query that uses the XML column to get your values instead.
Upvotes: 1