»ñÈ¡SQL ServerµÄµ±Ç°Á¬½ÓÊý
»ñÈ¡SQL ServerµÄµ±Ç°Á¬½ÓÊý
[ת]http://www.cnblogs.com/confach/archive/2006/05/31/414156.html
Ê×ÏÈÉùÃ÷:Õâ¸öÎÊÌâÎÒûÓнâ¾ö
µ±ÍøÓÑÎʵ½ÎÒÕâ¸öÎÊÌâʱ,ÎÒÒ²»¹ÒÔΪºÜ¼òµ¥,ÒÔΪSQL ServerÓ¦¸ÃÌṩÁ˶ÔÓ¦µÄϵͳ±äÁ¿Ê²Ã´µÄ.µ«Êǵ½Ä¿Ç°ÎªÖ¹,ÎÒ»¹Ã»Óеõ½Ò»¸ö±È½ÏºÃµÄ½â¾ö·½°¸.¿ÉÄܼܺòµ¥,,Ö»²»¹ýÎÒ²»ÖªµÀ°ÕÁË.Ï£ÍûÈç´Ë..
ÏÂÃæÎÒ˵˵Ïà¹ØµÄ֪ʶ°É.Ï£Íû´ó¼Ò¿ÉÒÔ¸ø³öÒ»¸ö±È½ÏºÃµÄ·½·¨.
ÕâÀïÓм¸¸öÓëÖ®Ïà¹ØµÄ¸ÅÄî.
SQL ServerÌṩÁËһЩº¯Êý·µ»ØÁ¬½ÓÖµ(ÕâÀï¿É²»Êǵ±Ç°Á¬½ÓÊýÓ´!),¸öÈ˾õµÃ,ºÜÈÝÒײúÉúÎó½â.
ϵͳ±äÁ¿
@@CONNECTIONS ·µ»Ø×ÔÉÏ´ÎÆô¶¯ Microsoft® SQL Server™ ÒÔÀ´Á¬½Ó»òÊÔͼÁ¬½ÓµÄ´ÎÊý¡£
@@MAX_CONNECTIONS ·µ»Ø Microsoft® SQL Server™ ÉÏÔÊÐíµÄͬʱÓû§Á¬½ÓµÄ×î´óÊý¡£·µ»ØµÄÊý²»±ØΪµ±Ç°ÅäÖõÄÊýÖµ¡£
ϵͳ´æ´¢¹ý³Ì
SP_WHO
Ìṩ¹ØÓÚµ±Ç° Microsoft® SQL Server™ Óû§ºÍ½ø³ÌµÄÐÅÏ¢¡£¿ÉÒÔɸѡ·µ»ØµÄÐÅÏ¢£¬ÒÔ±ãÖ»·µ»ØÄÇЩ²»ÊÇ¿ÕÏеĽø³Ì¡£
ÁгöËùÓлµÄÓû§:SP_WHO ‘active’
Áгöij¸öÌض¨Óû§µÄÐÅÏ¢:SP_WHO ‘sa’
ϵͳ±í
Sysprocesses
sysprocesses ±íÖб£´æ¹ØÓÚÔËÐÐÔÚ Microsoft® SQL Server™ ÉϵĽø³ÌµÄÐÅÏ¢¡£ÕâЩ½ø³Ì¿ÉÒÔÊÇ¿Í»§¶Ë½ø³Ì»òϵͳ½ø³Ì¡£sysprocesses Ö»´æ´¢ÔÚ master Êý¾Ý¿âÖС£
Sysperfinfo
°üÀ¨Ò»¸ö Microsoft® SQL Server™ ±íʾ·¨µÄÄÚ²¿ÐÔÄܼÆÊýÆ÷£¬¿Éͨ¹ý Windows NT ÐÔÄܼàÊÓÆ÷ÏÔʾ.
ÓÐÈËÌáÒé˵ΪÁË»ñÈ¡SQL ServerµÄµ±Ç°Á¬½ÓÊý:ʹÓÃÈçÏÂSQL:
SELECT COUNT(*) AS CONNECTIONS from master..sysprocesses
¸öÈËÈÏΪ²»¶Ô,¿´¿´.sysprocessesµÄlogin_timeÁоͿɿ´³ö.
ÁíÍâÒ»¸ö·½ÃæÊǽø³Ì²»ÄܺÍÁ¬½ÓÏàÌá²¢ÂÛ,ËûÃÇÊÇÒ»¶ÔÒ»µÄ¹ØϵÂð,Ò²¾ÍÊÇ˵һ¸ö½ø³Ì¾ÍÊÇÒ»¸öÁ¬½Ó?Ò»¸öÁ¬½ÓÓ¦¸ÃÓжà¸ö½ø³ÌµÄ,ËùÒÔÁ¬½ÓºÍ½ø³ÌÖ®¼äµÄ¹ØϵӦ¸ÃÊÇ1:nµÄ.
ÒòΪsysprocessesÁгöµÄ½ø³Ì°üº¬ÁËϵͳ½ø³ÌºÍÓû§½ø³Ì,ΪÁ˵õ½Óû§Á¬½Ó,¿ÉÒÔʹÓÃÈçÏÂSQL:
SELECT cntr_value AS User_Connections from master..sysperfinfo as p
WHERE p.object_name = 'SQLServer:General Statistics' And p.counter_name = 'User Connections'
¸öÈË»¹ÊÇÈÏΪ²»¶Ô,ÒòΪËüÊÇÒ»¸ö¼ÆÊýÆ÷,¿ÉÄÜ»áÀÛ¼ÓµÄ.
»¹ÓÐÒ»ÖÖ·½°¸ÊÇÀûÓÃÈçÏÂSQL:
select connectnum=count(distinct net_address)-1 from master..sysprocesses
ÀíÓÉÊÇnet_addressÊÇ·ÃÎÊÕß»úÆ÷
Ïà¹ØÎĵµ£º
String keyword = request.getParameter("keyword");
String timeRange = request.getParameter("timeRange");
String type = request.getParameter("type");
StringBuffer sql = new StringBuffer();
sql.append("use webstation_leadall s ......
MS SQL SERVER 2005È«ÎÄË÷Òýѧϰ±Ê¼ÇÒ»
ÏÈÁ˽âÒ»ÏÂÈ«ÎÄË÷ÒýÊÇÈçºÎ´´½¨ºÍʹÓõÄ
´´½¨È«ÎÄË÷Òý:
ÔÚMS SQL SERVER 2005Àï,È«ÎÄË÷ÒýÊÇÒ»¸öµ¥¶ÀµÄ·þÎñÏî,ĬÈÏÊÇÆô¶¯µÄ,µ«ÊÇûÓÐÔÊÐíÊý¾Ý¿âÆôÓÃÈ«ÎÄË÷Òý,Èç¹ûÒ ......
Ôʼ±í£º
name course score
-----------------------------------------
ÕÅÈý ÓïÎÄ 80
ÕÅÈý & ......
Êý¾Ý¿â±¸·ÝʵÀý/**
**Êý¾Ý¿â±¸·ÝʵÀý
**Öì¶þ 2004Äê5ÔÂ
**±¸·Ý²ßÂÔ:
**Êý¾Ý¿âÃû:test
**±¸·ÝÎļþµÄ·¾¶e:\backup
**ÿ¸öÐÇÆÚÌìÁ賿1µã×öÒ»´ÎÍêÈ«±¸·Ý,Ϊ±£ÏÕÆð¼û,±¸·Ýµ½Á½¸öͬÑùµÄÍêÈ«±¸·ÝÎļþtest_full_A.bakºÍtest_full_B.bak
**ÿÌì1µã(³ýÁËÐÇÆÚÌì)×öÒ»´Î²îÒ챸·Ý,·Ö±ð±¸·Ýµ½Á½¸öÎļþtest_df_A.bakºÍtest_df ......