常用脚本--SQL Server获取OS日志

--===================================================
--SQL Server获取OS日志:
declare @start_date varchar(21),
     @end_date varchar(21),
     @out_server varchar(50),
     @cmd varchar(200)
select @start_date='12/31/2012,11:59:59PM',
      @end_date='04/11/2013,11:59:59PM',
      @out_server='ebj2454'
select @start_date,@end_date
select @cmd='cscript c:\windows\system32\eventquery.vbs
     /FI "Datetime eq '+@start_date+'-'+@end_date+'"
     /FI "Type eq Warning" /L system /V '+N' -S '+
     @out_server  
exec xp_cmdshell  @cmd

 

你可能感兴趣的:(SQL Server)