SqlServer扩展存储过程

本文介绍如何在SQL Server中启用和使用扩展存储过程xp_cmdshell执行系统命令,并展示了通过xp_cmdshell调用SSIS包来加载数据文件的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 扩展存储过程xp_cmdshell用法:

--1.启用
SP_CONFIGURE 'show advanced options',1
RECONFIGURE
GO
SP_CONFIGURE 'xp_cmdshell',1
RECONFIGURE
GO
--2.用法
master..xp_cmdshell 'DIR D:\'
--3.关闭
SP_CONFIGURE 'xp_cmdshell', 0   
RECONFIGURE  
GO
SP_CONFIGURE 'show advanced options', 0  
RECONFIGURE 
GO
View Code

 2.利用Package(.dtsx)加载数据文件到DB中:

master..xp_cmdshell 
'F:\FCapSSISPkg\Scripts\Working\DTS\Binn\dtexec /FILE 
Package文件路径\PackageName.dtsx /DECRYPT XXXXXX 
/set \Package.Variables[Server].Value;"\".\"" 
/set \Package.Variables[ServerFIS].Value;"\".\"" 
/set \Package.Variables[BaseFolder].Value;"\"E:\要加载的文件的路径\"" 
/set \Package.Variables[参数名].Value;"\"参数值1\"" 
/set \Package.Variables[参数名].Value;"\"参数值1\""'
View Code

 

转载于:https://www.cnblogs.com/sccd/p/5535746.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值