Quantcast
Channel: Consulta Substring
Viewing all articles
Browse latest Browse all 4

Consulta Substring

$
0
0

Gregorio,

      Se isso é um XML é melhor você trabalhar com as ferramentas de XML do SQL Server...

      Veja um exemplo retirado do Books Online:

DECLARE @idoc int
DECLARE @doc varchar(1000)
SET @doc ='<ROOT><Customers CustomerID="VINET" ContactName="Paul Henriot"><Orders CustomerID="VINET" EmployeeID="5" OrderDate="1996-07-04T00:00:00"><Order_x0020_Details OrderID="10248" ProductID="11" Quantity="12"/><Order_x0020_Details OrderID="10248" ProductID="42" Quantity="10"/></Orders></Customers><Customers CustomerID="LILAS" ContactName="Carlos Gonzlez"><Orders CustomerID="LILAS" EmployeeID="3" OrderDate="1996-08-16T00:00:00"><Order_x0020_Details OrderID="10283" ProductID="72" Quantity="3"/></Orders></Customers></ROOT>'
--Create an internal representation of the XML document.
EXEC sp_xml_preparedocument @idoc OUTPUT, @doc
-- SELECT statement that uses the OPENXML rowset provider.
SELECT    *
FROM       OPENXML (@idoc, '/ROOT/Customers')
EXEC sp_xml_removedocument @idoc

Roberto Fonseca MCT / MCITP - Database Administrator 2008 MCITP - Database Developer 2008 MCITP - Business Intelligence 2008


Viewing all articles
Browse latest Browse all 4

Trending Articles