Hi @Naomi ,
The SSIS XML Source Adapter is for shredding XML into a relational/rectangular format.
There is no other task to process input XML file out-of-the-box in SSIS.
Your approach by using
SELECT ...
FROM OPENROWSET (BULK N'e:\temp\input.xml', SINGLE_BLOB)
is the best method to load XML file in its entirety.
Please update your question and add the entire error message.
Here is a minimal reproducuble example for you. You can create a stored procedure out of it, passing a single parameter: fully qualified path to XML file - @fileName
.
And call that SP in SSIS via Execute SQL Task.
DECLARE @tbl TABLE (ID INT IDENTITY PRIMARY KEY, xmldata XML);
DECLARE @sql NVARCHAR(MAX)
, @fileName VARCHAR(255) = N'e:\Temp\input.xml';
SET @sql = N'SELECT * FROM OPENROWSET (BULK ' + QUOTENAME(@fileName,NCHAR(39)) + ', SINGLE_BLOB) AS Tab(XmlDoc)';
INSERT INTO @tbl (xmldata)
EXEC sys.sp_executesql @sql;
-- test
SELECT * FROM @tbl;
Obviously, you would need permissions for that operation.
There are two ways to grant permissions for bulk operations.
(1) As a server level permission:
GRANT ADMINISTER BULK OPERATIONS TO [server_login]
(2) There is a Server-level role called [bulkadmin]. So, you could also add a user or group to that role:
ALTER SERVER ROLE [bulkadmin] ADD MEMBER [USERNAME];
(3) SQL Server may also return an error if the service account does not have permission to read the file being loaded. Ensure that the service account has read access to the file location.