SQL Server 数据库 触发器 执行外部程序需要使用 master..xp_cmdshell 进行外部exe的执行
使用master..xp_cmdshell 需要先开启xp_cmdshell
直接执行开启命令
--开启xp_cmdshell:
exec sp_configure 'show advanced options', 1;
reconfigure;
exec sp_configure 'xp_cmdshell', 1;
reconfigure;
exec sp_configure 'show advanced options', 0;
reconfigure;
--关闭xp_cmdshell:
exec sp_configure 'show advanced options', 1;
reconfigure;
exec sp_configure 'xp_cmdshell', 0;
reconfigure;
exec sp_configure 'show advanced options', 0;
reconfigure;
在触发器中调用
@InterID为参数
调用exe程序路径过长会无法调用
触发器调用Demo地址