----------------------- XML File loading into temp table ------------------------
-- Temp table creation
CREATE TABLE #Xlm
(
XML_Data xml
)
-- XML File loading
INSERT INTO #Xlm(XML_Data)
SELECT CONVERT(XML, BulkColumn) AS BulkColumn
FROM OPENROWSET(BULK 'C:\Kiran\SQLServer\SSRS\HyperLinksNew.xml', SINGLE_BLOB) AS x;
----------------------- Query to extract required URL from temp table ------------------------
DECLARE @XML AS XML, @hDoc AS INT, @SQL NVARCHAR (MAX)
SELECT @XML = XML_Data FROM #Xlm
EXEC sp_xml_preparedocument @hDoc OUTPUT, @XML
SELECT URL
FROM OPENXML(@hDoc, 'Invoice/InvoiceDetail')
WITH
(
URL [varchar](100) 'URL',
Description [varchar](100) 'Description',
ActiveFlg [varchar](100) 'ActiveFlg'
)
where description = 'Google'
AND ActiveFlg = 1
EXEC sp_xml_removedocument @hDoc
No comments:
Post a Comment