我试图从一个XML文件中的数据导入到数据库中。 我已经使用由测试脚本BULK INSERT
,但是当我活数据库上进行测试,其权限BULK
被禁用。
尝试#1:
BULK INSERT XMLTable FROM 'C:\Radu\test.xml' WITH (ROWTERMINATOR = '>');
所以,我继续研究,以找到一种方法来避免使用BULK
,发现其他选项,如OPENROWSET
和OPENDATASOURCE
。 但不幸的是,这些操作的权限都被撤销。
尝试#2:
SELECT *
FROM OPENROWSET('MSDASQL',
'Driver={Microsoft Text Driver (*.xml)};DefaultDir=C:\Radu\test.xml;',
'SELECT * FROM [test.xml];' )
导致错误:
Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.
我试图RECONFIGURE
权限这一点,但没有成功。
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;
RECONFIGURE;
也导致:
Msg 15247, Level 16, State 1, Procedure sp_configure, Line 94
User does not have permission to perform this action.
Msg 5812, Level 14, State 1, Line 2
You do not have permission to run the RECONFIGURE statement.
Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51
The configuration option 'Ad Hoc Distributed Queries' does not exist, or it may be an advanced option.
Msg 5812, Level 14, State 1, Line 4
You do not have permission to run the RECONFIGURE statement.
我仍然试图找到一个解决方案只是将信息导入数据库中,我并不需要特殊的格式,只是为了获得系统中的数据,但我非常希望导入每个XML行的记录我的表。
看来,我的大部分选项都断了,所以我会非常感激的任何建议。
更新:
我要创建一个存储过程导入此数据,因此,最好这将是通用的,与XML信息没有硬编码。