1、连接查询

select * from sysprocesses where dbid in (select dbid from sysdatabases where name='dbname')
--或者
SELECT * FROM
[Master].[dbo].[SYSPROCESSES] WHERE [DBID] IN ( SELECT
[DBID]
FROM
[Master].[dbo].[SYSDATABASES]
WHERE
NAME='dbname'
)

2、当前正在执行的sql查询

SELECT  [Spid] = session_id ,
ecid ,
[Database] = DB_NAME(sp.dbid) ,
[User] = nt_username ,
[Status] = er.status ,
[Wait] = wait_type ,
[Individual Query] = SUBSTRING(qt.text,
er.statement_start_offset / 2,
( CASE WHEN er.statement_end_offset = -1
THEN LEN(CONVERT(NVARCHAR(MAX), qt.text))
* 2
ELSE er.statement_end_offset
END - er.statement_start_offset )
/ 2) ,
[Parent Query] = qt.text ,
Program = program_name ,
hostname ,
nt_domain ,
start_time
FROM sys.dm_exec_requests er
INNER JOIN sys.sysprocesses sp ON er.session_id = sp.spid
CROSS APPLY sys.dm_exec_sql_text(er.sql_handle) AS qt
WHERE session_id > 50 -- Ignore system spids.
AND session_id NOT IN ( @@SPID ) -- Ignore this current statement.
ORDER BY 1 ,

清理存储过程预编译等缓存、会话缓存、系统缓存、缓存区

 DBCC FREEPROCCACHE
DBCC FREESESSIONCACHE
DBCC FREESYSTEMCACHE('All')
DBCC DROPCLEANBUFFERS
--内存使用情况
SELECT * FROM sys.dm_os_performance_counters
WHERE counter_name IN ('Target Server Memory (KB)','Total Server Memory (KB)') -- 内存状态
DBCC MemoryStatus --查看最小最大内存
SELECT
cfg.name AS [Name],
cfg.configuration_id AS [Number],
cfg.minimum AS [Minimum],
cfg.maximum AS [Maximum],
cfg.is_dynamic AS [Dynamic],
cfg.is_advanced AS [Advanced],
cfg.value AS [ConfigValue],
cfg.value_in_use AS [RunValue],
cfg.description AS [Description]
FROM
sys.configurations AS cfg --设置最小最大内存 sp_configure 'show advanced options', 1 go
sp_configure 'min server memory', 0
RECONFIGURE
GO sp_configure 'max server memory', 2147483647
RECONFIGURE
GO sp_configure 'max server memory', 256
RECONFIGURE
GO
sp_configure 'show advanced options', 0
CREATE proc [dbo].reclaimmemory  --强制释放内存

as

begin

 DBCC FREEPROCCACHE
DBCC FREESESSIONCACHE
DBCC FREESYSTEMCACHE('All')
DBCC DROPCLEANBUFFERS exec sp_configure 'max server memory', 256
EXEC ('RECONFIGURE' ) WAITFOR DELAY '00:00:05' EXEC sp_configure 'max server memory', 2147483647
EXEC ('RECONFIGURE' )
GO end

最新文章

  1. js如何求一组数中的极值
  2. 编译可供C#调用的C/C++动态链接库dll文件
  3. NOIP 考前 Tarjan复习
  4. MSSQL数据库中Text类型字段在PHP中被截断之解 (转)
  5. ios auto layout demystified (一)
  6. 基于MySQL协议的数据库中间层项目Atlas - 360团队
  7. Java基础知识强化之集合框架笔记50:Map集合之Map集合的概述和特点
  8. 查看Android系统当前运行的activity
  9. HttpWatch工具简介及使用技巧(转载)
  10. 深入探讨 ECMAScript 规范第五版
  11. 使用getCurrentPosition方法实时获取当前Geolocation信息(赋源码文件)--html5、JavaScript
  12. fiddler实现手机抓包
  13. 移动开发的捷径:3种方式轻松创建webapp
  14. Confluence 6 数据库字符集编码和问题
  15. 对象何时进入老年代、何时发生full gc
  16. DevExpress GridView 整理(转)
  17. Network-Emulator Network-Emulator-Toolkit网络模拟器使用详细介绍
  18. Poj2296
  19. Java关键字(二)——native
  20. emulator: ERROR: x86 emulation currently requires hardware acceleration!Please ensure Intel HAXM is properly installed and usable.CPU acceleration status: HAX kernel module is not installed!

热门文章

  1. BC26模组UDP调试
  2. Linux 内核错误码
  3. javascript之new操作符
  4. 使用Jenkins的Git Parameter插件来从远程仓库拉取指定目录的内容
  5. VMware Workstation Pro 15 序列号
  6. SQL查看数据库中每张表的数据量和总数据量
  7. Go 操作 Mysql(二)
  8. 13 个 JS 数组精简技巧
  9. 1+x证书学习日志——css常用属性
  10. (一)react-native开发系列之Mac开发环境配置