解决方案: |
在SQL企业管理器中新建作业,让定期执行下面的语句:
declare @date varchar(8),@sql varchar(200),@time varchar(10)
set @date=cast(year(getdate()) as varchar(4))+(case when month(getdate())<10 then ('0'+cast(month(getdate()) as varchar(1))) else cast(month(getdate()) as varchar(2)) end)+(case when day(getdate())<10 then ('0'+cast(day(getdate()) as varchar(1))) else cast(day(getdate()) as varchar(2)) end)
set @time=cast(getdate() as varchar(10))
set @sql='bcp "'+'select * from ufsystem..ua_log where dintime <'+''''+@time+''''+'" '+'queryout '+'存放日志的目录out'+@date+'.txt'+' -c'+' -P'+' -q'+' -k'
exec master..xp_cmdshell @sql
delete from ufsystem..ua_log where dintime
|