Create proc Test
as
DECLARE @errCode int
DECLARE @fso int
EXEC @errCode = sp_OACreate 'Scripting.FileSystemObject', @fso OUT
if @errCode <> 0
BEGIN
DECLARE @description varchar(256)
EXEC sp_OAGetErrorInfo @fso, NULL, @description OUT
PRINT @description /*SQL 查询分析器中有效*/
END
DECLARE @f int
EXEC sp_OAMethod @fso, 'CreateTextFile', @f OUT, 'C:/oo.txt', 1
EXEC sp_OAMethod @f, 'Write', NULL, 缓存依赖文件不得删除
EXEC sp_OAMethod @f, 'Close' /*等效于:f.Close*/
EXEC sp_OADestroy @f /*等效于:set f = nothing*/
EXEC sp_OADestroy @fso
Create TRIGGER WriteCacheDepFile ON Procurement
FOR INSERT, UPDATE, DELETE
AS
Exec Test