最近闲的没事,为了以后的工作提高效率,其实是不想让自己的眼睛和手 太累。于是写了如下脚本 来解放自己。 ---查看每个磁盘剩余空间大小(M)Exec master.dbo.xp_fixeddrives --或者declare @Fixed_tb table(Drive_NO char(1),Remainder_M bigint)INSERT INTO @Fixed_tb exec master.dbo.xp_fixeddrivesselect Drive_NO '驱动盘符',Remainder_M'剩余M',cast(((Remainder_M/1024)+0.001*(Remainder_M%1024))as dec(18,2))'剩余G' from @Fixed_tbGO-----SQL SERVER 日志 declare @tmp table (LogDate datetime,ProcessInfo varchar(32),Text nvarchar(max))insert into @tmpEXEC master.dbo.xp_readerrorlog 0, 1, NULL, NULL, NULL, NULL, N'desc'---读取SQL Server 日志select * from @tmp where 1=1/* 一共有7个参数: 1. 存档编号2. 日志类型(1为SQL Server日志,2为SQL Agent日志)3. 查询包含的字符串4. 查询包含的字符串5. LogDate开始时间6. 结果排序,按LogDate排序(可以为降序"Desc" Or 升序"Asc")7. 结果排序,按LogDate排序(可以为降序"Desc" Or 升序"Asc") 在输入第5和第6个参数的时候,使用时间里包含有秒、毫秒时候,有时候查询速度非常慢,而且导致CPU占用率为100%。*/--作业活动监视器 详细内容SELECT c.job_id,a.name,case when a.enabled =1 then '是' else '否' end '是否启用', a.date_created '创建时间',a.date_modified '修改时间', left(b.last_run_date,4)+'/'+SUBSTRING(convert(varchar(8),b.last_run_date),5,2)+'/'+right(b.last_run_date,2)+' '+ case when b.last_run_time=0 then '0:00:00' when LEN(b.last_run_time)=3 then '0:0'+SUBSTRING(convert(varchar(6),b.last_run_time),1,1)+':'+RIGHT(b.last_run_time,2) when LEN(b.last_run_time)=4 then '0:'+LEFT(b.last_run_time,2)+':'+RIGHT(b.last_run_time,2) when len(b.last_run_time)=5 then left(b.last_run_time,1)+':'+SUBSTRING(convert(varchar(6),b.last_run_time),2,2)+':'+right(b.last_run_time,2) else left(b.last_run_time,2)+':'+SUBSTRING(convert(varchar(6),b.last_run_time),3,2)+':'+right(b.last_run_time,2)end'上次运行时间', left(c.next_run_date,4)+'/'+SUBSTRING(convert(varchar(8),c.next_run_date),5,2)+'/'+right(c.next_run_date,2)+' '+ case when c.next_run_time=0 then '0:00:00' when LEN(c.next_run_time)=3 then '0:0'+SUBSTRING(convert(varchar(6),c.next_run_time),1,1)+':'+RIGHT(c.next_run_time,2) when LEN(c.next_run_time)=4 then '0:'+LEFT(c.next_run_time,2)+':'+RIGHT(c.next_run_time,2) when len(c.next_run_time)=5 then left(c.next_run_time,1)+':'+SUBSTRING(convert(varchar(6),c.next_run_time),2,2)+':'+right(c.next_run_time,2) else left(c.next_run_time,2)+':'+SUBSTRING(convert(varchar(6),c.next_run_time),3,2)+':'+right(c.next_run_time,2)end '下次运行时间', case when substring(b.last_outcome_message,1,CHARINDEX('。', b.last_outcome_message)) is NULL then '未知' else substring(b.last_outcome_message,1,CHARINDEX('。', b.last_outcome_message)) end '上次运行结果'FROM[msdb].[dbo].[sysjobs_view] a join [msdb].[dbo].[sysjobservers] bon a.job_id =b.job_id join [msdb].[dbo].[sysjobschedules] con a.job_id =c.job_id where a.category_id =0 or a.category_id =3----每个作业详细运行步骤及结果select a.name ,a.description,a.date_created,a.date_modified, b.message, left(b.run_date,4)+'/'+SUBSTRING(convert(varchar(8),b.run_date),5,2)+'/'+right(b.run_date,2)+' '+ case when b.run_time=0 then '0:00:00' when LEN(b.run_time)=3 then '0:0'+SUBSTRING(convert(varchar(6),b.run_time),1,1)+':'+RIGHT(b.run_time,2) when LEN(b.run_time)=4 then '0:'+LEFT(b.run_time,2)+':'+RIGHT(b.run_time,2) when len(b.run_time)=5 then left(b.run_time,1)+':'+SUBSTRING(convert(varchar(6),b.run_time),2,2)+':'+right(b.run_time,2) else left(b.run_time,2)+':'+SUBSTRING(convert(varchar(6),b.run_time),3,2)+':'+right(b.run_time,2)end'运行时间', case when b.run_status=1 then '成功' else '失败' end '状态' FROM [msdb].[dbo].[sysjobs_view] a ,[msdb].[dbo].[sysjobhistory] b where a.job_id =b.job_id and (a.category_id =0 or a.category_id =3)
详细解决方案
读取SQL SERVER日记及代理日志
热度:73 发布时间:2016-05-05 13:34:20.0
相关解决方案
- myeclipse联接sql server 2008看不到用户表
- Server Tomcat v7.0 Server不能起步
- 在哪找的SQL Server 2005数据库驱动文件?为什么sql server2005安装盘上面没有找到
- The server encountered an internal error () that prevented it from fulfilling th解决方案
- JSP运行异常 STRUTS + SQL SERVER 2005
- jsp连接sql server 2005时出现的异常
- jsp连接sql server 2005数据库是异常!
- 大家帮帮忙呀The server encountered an internal error () that prevented it解决方法
- ASP上Set GetSession("conn")=server.CreateObject("adodb.connection")
- Server Apache Tomcat v6.0.35 at localhost failed to start
- JDBC 连接sql server 2005老是失败怎么处理?恳请高手帮忙。
- SOS-(奇怪现象)服务器暂不可用500 internal server error,该怎么解决
- tomcat没法运行Could not publish to the server. Error while expanding
- sql server 设置非空默认值之后,hibernate添加出现异常
- WEBstruts The server encountered an internal error () that prevented it fr解决思路
- jsp连接sql server 2005错误
- 可以安装在win7系统的sql server
- 出现异常:cvs [server aborted]:"passwd" requires write access to the repository
- exchange server 2000提供全部用户邮件到达的java api吗
- jdbc 直连sql server 2000 连不下
- Error 500-Internal Server Error 如何解决
- JAVA连接SQL SERVER 2000数据库,该如何解决
- Server returned HTTP response code: 403 for URL如何解决
- IM聊天系统的有关问题,用Tigase Server 如何实现挤线功能
- com.microsoft.sqlserver.jdbc.SQLServerException: 用户 'sa' 登录失败。该用户与可托 SQL Server
- Error 500--Internal Server Error
- Error 500-Internal Server Error
- jbuilder2006 连接 sql server 2000新有关问题
- java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]l??????? hstmt
- eclipse中不能筑tomcat server