SQL 读数据可以用BCP导入文本文件,写也可以通过BCP.
如果写LOG可以通过COMSHELL
FOR EXAMPLE:
...
select @szLogMsg = "@echo "
select @szLogMsg = @szLogMsg + convert(varchar, GetDate(), 108) + " -- "
-- message
select @szLogMsg = @szLogMsg + "HOST EXTRACT PROCEDURE STARTED"
-- postfix
select @szLogMsg = @szLogMsg + " >>" -- must start with blank!
-- exec (log file)
select @tmpstr = @szLogMsg + @szLogFilename
exec @rcexec = master..xp_cmdshell @tmpstr, no_output
-- exec (weekday log file)
select @tmpstr = @szLogMsg + @szWdayFilename
exec @rcexec = master..xp_cmdshell @tmpstr, no_output
如果写LOG可以通过COMSHELL
FOR EXAMPLE:
...
select @szLogMsg = "@echo "
select @szLogMsg = @szLogMsg + convert(varchar, GetDate(), 108) + " -- "
-- message
select @szLogMsg = @szLogMsg + "HOST EXTRACT PROCEDURE STARTED"
-- postfix
select @szLogMsg = @szLogMsg + " >>" -- must start with blank!
-- exec (log file)
select @tmpstr = @szLogMsg + @szLogFilename
exec @rcexec = master..xp_cmdshell @tmpstr, no_output
-- exec (weekday log file)
select @tmpstr = @szLogMsg + @szWdayFilename
exec @rcexec = master..xp_cmdshell @tmpstr, no_output
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=359&lngWId=5