select instance_id,jh.run_date,jh.job_id,jh.step_name, case jh.run_status then 'failed' then 'Succeeded' then 'Retry' then 'Canceled' end as run_status ,) as '开始时间' ,) ) as '秒',jh.run_duration,jh.run_time from msdb.dbo.sysjobhistory jh with(nolock) w
转:https://www.cnblogs.com/pacer/archive/2010/03/02/1676371.html [sqlserver]: sqlserver 认为 null 最小. 升序排列:null 值默认排在最前. 要想排后面,则:order by case when col is null then 1 else 0 end ,col 降序排列:null 值默认排在最后. 要想排在前面,则:order by case when col is null then 0 el
表数据: 按名称排序 并不能得到一二三四五六的顺序 select * from LiWei order by name 找到中文数字在'一二三四五六七八九十'的位置 select id,name,SUBSTRING(name,2,1) as 中文数字,charindex(SUBSTRING(name,2,1),'一二三四五六七八九十') as 中文数字所在位置 from LiWei 按中文所在位置排序 select * from LiWei order by charindex(SUBSTRIN
--1. row_number 用法 这个函数的功能是为查询出来的每一行记录生成一个序号select row_number() over(order by stuid) as row_number,* from score with t_rowtableas( select row_number() over(order by stuid) as row_number,*from Score)select * from t_rowtable where row_number>1 and row_
use [数据库名] select last_execution_time '最近一次执行时间' from sys.dm_exec_procedure_stats where type='P' and database_id=db_id('[数据库名]') and object_id=object_id('[存储过程名]')
一.查询视图.函数.存储过程中的关键字 SELECT a.name,a.[type],b.[definition] FROM sys.all_objects a,sys.sql_modules b WHERE a.is_ms_shipped=0 AND a.object_id = b.object_id AND a.[type] IN ('P','V','AF') AND b.[definition] LIKE '%关键字%'ORDER BY a.[name] 二.作业中的关键字 SELECT
首先,我想说,我真的是渣了,一个这个玩意弄了半天,算了,直接切入正题吧. 第一步: 先写好存储过程 用了两张表,你们自己建立吧 <br data-filtered="filtered">if exists(select name from sysobjects where name='StaySchoolNum'and type='p') drop proc StaySchoolNum go create pr
set statistics profile onset statistics io onset statistics time onGO select * from mytable; goset statistics profile offset statistics io offset statistics time off
有些时候,有些作业遇到问题执行时间过长,因此我写了一个脚本可以根据历史记录,找出执行时间过长的作业,在监控中就可以及时发现这些作业并尽早解决,代码如下: SELECT sj.name , sja.start_execution_date,DATEDIFF (SECOND ,sja.start_execution_date,GETDATE() ) AS ExecutedMin,ja.AvgRuntimeOnSucceed FROM msdb.dbo.sysjobactivity AS