SQL to retrieve content of xml file.
DECLARE @file VARCHAR(MAX) = 'C:\Directory01\File01.xml',
@xml XML,
@COMMAND NVARCHAR(MAX),
@PARAM_DEF NVARCHAR(500),
@FILEVAR NVARCHAR(MAX),
@XML_OUT XML
SET @FILEVAR = @file
SET @PARAM_DEF = N'@XML_FILE NVARCHAR(MAX), @XML_OUT XML OUTPUT'
SET @COMMAND = N'SELECT @XML_OUT = BulkColumn FROM OPENROWSET(BULK ''' + @file + ''', SINGLE_BLOB) ROW_SET';
EXEC sp_executesql @COMMAND, @PARAM_DEF, @XML_FILE = @FILEVAR, @XML_OUT = @xml OUTPUT;
SELECT CONVERT(VARCHAR(MAX),@xml), @FILEVAR, @XML_OUT
Comments