易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL SERVER 查看CPU利用率

 --查看CPU利用率
-- CREATE PROCEDURE sp_GetTop10_CPU () AS
BEGIN
  SET NOCOUNT ON
  DECLARE @cinterval char(8)
  DECLARE @interval int
  SET @cinterval = '00:00:10'
  CREATE TABLE #thread
  (
    RUN INT NOT NULL,
    SPID INT NOT NULL,
    THREAD INT NULL,
    STATUS varchar(30) NOT NULL,
    [IO] INT NOT NULL,
    CPU INT NOT NULL,
    MEM INT NOT NULL,
    LOCKS int NOT NULL,
    BLK INT NOT NULL,
    hostname varchar(30) NOT NULL,
    hostprocess INT NOT NULL
    CONSTRAINT PK_thread1 PRIMARY KEY CLUSTERED (RUN,SPID)
  )
  INSERT #thread
  SELECT 1,pr.spid,pr.kpid,pr.status,pr.physical_io,pr.cpu, pr.memusage,ISNULL(count(lk.spid),0),pr.blocked , max(pr.hostname), max(pr.hostprocess)
  from   master.dbo.sysprocesses pr
  LEFT OUTER JOIN  master.dbo.syslocks  lk
  ON pr.spid = lk.spid
  WHERE pr.spid>=50 AND pr.spid<>@@SPID
  GROUP BY pr.spid,pr.kpid,pr.status,pr.physical_io, pr.cpu,pr.memusage,pr.blocked
  WAITFOR DELAY @cinterval
  INSERT #thread
  SELECT 2,pr.spid,pr.kpid,pr.status,pr.physical_io,pr.cpu, pr.memusage,ISNULL(count(lk.spid),0),pr.blocked , max(pr.hostname), max(pr.hostprocess)
  from   master.dbo.sysprocesses pr
  LEFT OUTER JOIN  master.dbo.syslocks  lk
  ON pr.spid = lk.spid
  WHERE pr.spid>=50 AND pr.spid<>@@SPID
  GROUP BY pr.spid,pr.kpid,pr.status,pr.physical_io, pr.cpu,pr.memusage,pr.blocked
  SELECT TOP 10 T.*
  from
  (
    SELECT a.SPID, a.hostname, b.hostprocess, b.STATUS, (b.CPU-a.CPU) as 'CPU'
    from #thread a
    JOIN #thread b
    ON a.SPID=b.SP


相关文档:

Sql Server 2005/2008备份/删除过期备份T

 USE [master]
GO
/****** 对象:  StoredProcedure [dbo].[sp_backupdatabase]    脚本日期: 07/15/2009 16:23:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE proc [dbo].[sp_backupdatabase]
@bak_path nvarchar(4000)='',       ......

SQL Server和Oracle的常用函数对比

 ---------数学函数
1.绝对值
S:select abs(-1) value
O:select abs(-1) value from dual
2.取整(大)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.取整(小)
S:select floor(-1.001) value
O:select floor(-1.001) value from dual
4.取整(截取)
S:select cast ......

SQL注入攻击

 SQL注入攻击是黑客对数据库进行攻击的常用手段之一。随着B/S模式应用开发的发展,使用这种模式编写应用程序的程序员也越来越多。但是由于程序员的水平及经验也参差不齐,相当大一部分程序员在编写代码的时候,没有对用户输入数据的合法性进行判断,使应用程序存在安全隐患。用户可以提交一段数据库查询代码,根据程序 ......

用mysql源码进行SQL解析

http://blog.csdn.net/iamstillzhang/archive/2007/04/01/1548377.aspx
用mysql源码进行SQL解析
Mysql是通过yacc进行SQL语句解析的,这里介绍一下如何使用mysql的源码进行SQL语句解析。由于Mysql的源代码注释比较少,而且缺少资料,所有些地方研究不够深入。
1        Filed介绍
MY ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号