如何在 SQL Server 2008 存储过程中读取配置文件键
问题描述:
我的 c://config
settings.config
有以下内容:
<filelocation>d://mydata</filelocation>
现在我想在我的 SQL Server 2008 存储过程中获取 d://mydata
文件路径,它将把这个位置作为文件创建路径的输入.
Now I want to get d://mydata
file path in my SQL Server 2008 stored procedure, which will take this location as input for file creation path.
请推荐!!
答
简化示例,但您可以执行以下操作(假设您可以从 SQL Server 读取文件):
Simplified example but you could do something like this (assuming you can read the file from SQL Server):
declare @table table (Value XML)
insert @table
select a.* from openrowset (bulk 'C:\config', single_clob) a
select * from @table
select Value.value('filelocation[1]', 'varchar(100)')
from @table
根据文件结构进行扩展.
Extend based on structure of your file.