Sql Server觸發器調用exe控制檯程序

Sql Server觸發器調用exe程序

先在Sql Server中添加啓動,需要手動啓動(我用的是2019)

-- 啓用 xp_cmdshell
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE
--- 執行過程 EXEC xp_cmdshell
'D:\bin\Debug\net8.0\DownloadImg.exe'

 

創建觸發器

CREATE TRIGGER InsertIMG on SystemLog
AFTER INSERT
AS
BEGIN
EXEC xp_cmdshell 'D:\bin\Debug\net8.0\DownloadImg.exe'
END

插入數據之後觸發,親測確實是觸發了,但最後一條數據沒有到想要的結果中,待補充........

insert into SystemLog (Date ,thread) values(GETDATE(),'https://q8.itc.cn/q_70/images03/20240421/e0a5f758921840449f1561e206243211.jpeg')

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章