SQL Server 2005 ϵͳÊý¾Ý½éÉÜ£ºsys.dm_exec_requests
Õë¶Ô SQL Server ÄÚÕýÔÚÖ´ÐеÄÿ¸öÇëÇó·µ»ØÒ»ÐС£sys.dm_exec_connections
¡¢sys.dm_exec_sessions
ºÍsys.dm_exec_requests
·þÎñÆ÷·¶Î§¶¯Ì¬¹ÜÀíÊÓͼӳÉäµ½ sys.sysprocesses
ϵͳÊÓͼ£¨ÏÈǰΪϵͳ±í£©¡£
×¢Ò⣺
ÈôÒªÖ´ÐÐÔÚ SQL Server ÒÔÍâµÄ´úÂ루ÀýÈ磬À©Õ¹´æ´¢¹ý³ÌºÍ·Ö²¼Ê½²éѯ£©£¬Ôò±ØÐëÔÚ·ÇÇÀÏȼƻ®³ÌÐòµÄ¿ØÖÆ·¶Î§ÒÔÍâÖ´ÐиÃÏ̡߳£ÈôÒªÕâÑù×ö£¬¹¤×÷Ï߳̽«Çл»µ½ÇÀÏÈģʽ¡£Óɴ˶¯Ì¬¹ÜÀíÊÓͼ·µ»ØµÄʱ¼äÖµ²»°üÀ¨ÔÚÇÀÏÈģʽÏ»¨·ÑµÄʱ¼ä¡£
ÁÐÃû
Êý¾ÝÀàÐÍ
˵Ã÷
session_id
smallint
Óë´ËÇëÇóÏà¹ØµÄ»á»°µÄ ID¡£²»¿ÉΪ¿ÕÖµ¡£
request_id
int
ÇëÇóµÄ ID¡£ÔڻỰµÄÉÏÏÂÎÄÖÐÊÇΨһµÄ¡£²»¿ÉΪ¿ÕÖµ¡£
start_time
datetime
¼Æ»®ÔËÐÐÇëÇóµÄʱ¼ä¡£²»¿ÉΪ¿ÕÖµ¡£
status
nvarchar(60)
ÇëÇóµÄ״̬¡£¿ÉÄܵÄÖµ°üÀ¨£º
ºǫ́¡£ÇëÇóÊǺǫ́Ị̈߳¬ÀýÈç×ÊÔ´¼àÊÓÆ÷»òËÀËø¼àÊÓÆ÷¡£
ÕýÔÚÔËÐС£ÇëÇóÕýÔÚÔËÐС£
¿ÉÔËÐС£ÇëÇóÕýÔÚÔËÐУ¬ÓÉÓÚÖٲò»×㣬Òò´ËÒªÁÙʱ½øÐÐÍ×ÉÆ°²ÅÅ¡£
˯Ãß¡£Ã»ÓÐÒª×öµÄ¹¤×÷¡£
¹ÒÆð¡£ÇëÇóÕýÔڵȴý¹¤×÷Ïß³ÌÑ¡È¡¡£
ÒѹÒÆð¡£ÇëÇóÕýÔڵȴýij¸öʼþ¡£
²»¿ÉΪ¿ÕÖµ¡£
command
nvarchar(32)
±êʶÕýÔÚ´¦ÀíµÄÃüÁîµÄÀàÐÍ¡£³£ÓÃÃüÁîÀàÐÍ°üÀ¨£º
SELECT
INSERT
UPDATE
DELETE
BACKUP LOG
BACKUP DB
DBCC
WAITFOR
ͨ¹ý½áºÏʹÓà sys.dm_exec_sql_text
¶¯Ì¬¹ÜÀíº¯ÊýºÍÇëÇóµÄÏàÓ¦ sql_handle
£¬¿ÉÒÔ¼ìË÷¸ÃÇëÇóµÄÎı¾¡£ÄÚ²¿ÏµÍ³½ø³Ì½«»ùÓÚËüÃÇËùÖ´ÐеÄÈÎÎñÀàÐÍÀ´ÉèÖøÃÃüÁî¡£ÕâЩÈÎÎñ¿ÉÒÔ°üÀ¨£º
LOCK MONITOR
CHECKPOINTLAZY
WRITER
²»¿ÉΪ¿ÕÖµ¡£
sql_handle
varbinary(64)
ÇëÇóµÄ SQL Óï¾ä¾ä±ú¡£¸Ã¾ä±ú¿ÉÓÃÓÚͨ¹ýsys.dm_exec_sql_text
¶¯Ì¬¹ÜÀíº¯Êý¼ìË÷ʵ¼ÊÓï¾äÎı¾¡£²»¿ÉΪ¿ÕÖµ¡£
statement_start_offset
int
Ö´ÐÐÅú´¦Àí»ò´æ´¢¹ý³ÌÖеÄÖ´ÐÐÓï¾äµÄ¿ªÊ¼×Ö·ûλÖ᣿ÉÒÔÓëstatement_end_offset
¡¢sys.dm_exec_sql_text
¶¯Ì¬¹ÜÀíº¯ÊýºÍ sql_handle
Ò»ÆðʹÓã¬ÎªÇëÇó¼ìË÷ÕýÔÚÖ´ÐеÄÓï¾ä¡£¿ÉΪ¿ÕÖµ¡£
statement_end_offset
int
Ö´ÐÐÅú´¦Àí»ò´æ´¢¹ý³ÌÖÐÕýÔÚÖ´ÐеÄÓï¾äµÄ½áÊø×Ö·ûλÖ᣿ÉÒÔÓëstatement_start_offset
¡¢sys.dm_exec_sql_text
¶¯Ì¬¹ÜÀíº¯ÊýºÍ sql_handle
Ò»ÆðʹÓã¬ÎªÇëÇó¼ìË÷ÕýÔÚÖ´ÐеÄÓï¾ä¡£¿ÉΪ¿ÕÖµ¡£
plan_handle
varbinary(64)
ÇëÇóµÄ²é
Ïà¹ØÎĵµ£º
sql server³öÏÖÑ¡¶¨µÄÓû§ÓµÓжÔÏó¶øÎÞ·¨É¾³ýµÄ´¦Àí
2006-4-5 19:50:00
·½·¨Ò»
Ê×ÏÈÄãÐèÒª×öµÄµÚÒ»¼þÊÂ
ÆóÒµ¹ÜÀíÆ÷-¡µÑ¡Ôñ·þÎñÆ÷-¡µÊô***-¡µ·þÎñÆ÷ÉèÖÃ-¡µÌôÉÏÔÊÐí¶ÔϵͳĿ¼¡£¡£¡£-¡µÈ·¶¨
µÚ¶þ²½
ÕÒµ½ÄãµÄÊý¾Ý¿âÕÒµ½sysusers±íÄÇÄãÒÔÇ°µÄÓû§É¾³ý
µÚÈý²½»ØÈ¥°ÉÊô***Öµ¸Ä»ØÀ´
µÚËIJ¿Öؽ¨Óû§¼´¿É
·½·¨¶þ
¶ ......
* ×î½üÒòΪ¿ª·¢»î¶¯ÐèÒª,ÓÃÉÏÁËEclipse,²¢ÒªÇóʹÓþ«¼ò°æµÄSQL(¼´ 2005)À´½øÐпª·¢ÏîÄ¿ *
1.×¼±¸¹¤×÷: ×¼±¸Ïà¹ØµÄÈí¼þ(Eclipse³ýÍâ,¿ªÔ´Èí¼þ¿ÉÒÔ´Ó¹ÙÍøÏÂÔØ)
<1>.Microsoft 2005 Express Edition
ÏÂÔصØÖ·:http://download.microsoft.com/download/0/9/0 ......
ÈçºÎÅжÏ×Ö¶ÎÊÇ·ñ´æÔÚ
if col_length('±íÃû','×Ö¶Î1') is null ALTER TABLE ±íÃû ADD ×Ö¶Î1 Nvarchar(50) if col_length('±íÃû','×Ö¶Î2') is null ALTER TABLE ±íÃû ADD ×Ö¶Î2 Nvarchar(50) ");
ɾ³ý×Ö¶Î
if col_length('±íÃû','×Ö¶Î1,') is not null ALTER TABLE ±íÃû drop c ......
·½·¨(1)
SELECT stuff((select ','+ltrim(ColumnName) from #A for xml path('')
),1,1,'')
/*
102,103,104,105
*/
·½·¨(2)
DECLARE @s NVARCHAR(1000)='';
SELECT @s+=ColumnName+',' from #A;
SELECT @s; ......
ÓÐʱÎÒÃÇ»áÏñÏÂÃæµÄÇé¿öÒ»Ñù£¬ÎªÖ÷±íµÄıһÌõ¼Ç¼£¬ÔÚÖмä±í(T_Stud_Course ±í)ÖÐͬʱ²åÈë¶àÌõÊý¾Ý
T_Student ±í
Stud_ID
Name
1
Tom
2
Jack
T_Course ±í
Course_ID
Course
1
Chinese
2
English
T_Stud_Course ±í
ID
Stud_ID
Course_ID
1
1
1
2
1
2
3
2
2
ÏÖÔÚÎÒÃÇ¿ÉÒÔÏÂÃæµÄ´æ´¢¹ý³ÌÀ ......