Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÈçºÎ¼ì²éSQL Server CPUÆ¿¾±

--¼ì²âCPUѹÁ¦µÄÒ»¸ö·½·¨ÊǼÆËãÔËÐÐ״̬ÏµĹ¤×÷½ø³ÌÊýÁ¿£¬
--ͨ¹ýÖ´ÐÐÈçϵÄDMV²éѯ¿ÉÒԵõ½Õâ¸öÐÅÏ¢
SELECT COUNT(*) AS workers_waiting_for_cpu,t2.scheduler_id
from sys.dm_os_workers AS t1, sys.dm_os_schedulers AS t2
WHERE t1.state='RUNNABLE' AND 
t1.scheduler_address = t2.scheduler_address AND
 t2.scheduler_id<255
GROUP BY t2.scheduler_id
--Ò²¿ÉÒÔÖ´ÐÐÈçϵIJéѯµÃµ½¹¤×÷½ø³ÌÔÚ¿ÉÔËÐÐ״̬Ï»¨·ÑµÄʱ¼ä
SELECT SUM(signal_wait_time_ms) from sys.dm_os_wait_stats
--ÏÂÃæÊÇÒ»¸öDMV²éѯ£¬Ëü¿ÉÒÔÓÃÀ´ÕÒ³öÿ´ÎÖ´ÐÐÖÐÕ¼ÓÃCPU×î¶àµÄÇ®10Ϊ²éѯ£¬
--Ò²ÁгöÁËSQLÓï¾äµÄ²éѯ¼Æ»®¼°¼Æ»®±»Ö´ÐеĴÎÊý¡£Èç¹ûÒ»¸ö²éѯ´ó¼ÒËä¸ß£¬
--µ«Ö´ÐдÎÊýÉÙ£¬ÄÇÒ²¿ÉÒÔ²ÉÄÉ¡£
SELECT TOP 10
total_worker_time/execution_count AS avg_cpu_cost, plan_handle,execution_count,
    (SELECT SUBSTRING(text,statement_start_offset/2+1,
        (CASE WHEN statement_end_offset=-1
        THEN LEN(CONVERT(NVARCHAR(max),text))*2
        ELSE statement_end_offset
        END -statement_start_offset)/2)
    from sys.dm_exec_sql_text(sql_handle)
    ) AS query_text
from sys.dm_exec_query_stats
ORDER BY [avg_cpu_cost] DESC
--ÒÔÉÏDMVÖ»ÏÔʾµ±Ç°±»»º´æµÄ²éѯºÏ¼Æͳ¼ÆÐÅÏ¢
--ΪÁËÕÒ³ö¹¤×÷¸ººÉÖÐÔËÐÐ×îƵ·±µÄ²éѯ£¬¾ÍÐèÒªÖ´ÐÐÏÂÃæµÄDMV²éѯ¡£
SELECT TOP 10 total_worker_time ,plan_handle,execution_count,
    (SELECT SUBSTRING(text,statement_start_offset/2+1,
        (CASE WHEN statement_end_offset=-1
        THEN LEN(CONVERT(NVARCHAR(max),text))*2
        ELSE statement_end_offset
        END -statement_start_offset)/2)
    from sys.dm_exec_sql_text(sql_handle)
    ) AS query_text
from sys.dm_exec_query_stats ORDER BY execution_count
--SQL ServerÔÚÓÅ»¯²éѯ¼Æ»®ÉÏ»¨·ÑµÄʱ¼ä¿ÉÒÔÓÃÏÂÃæµÄDM


Ïà¹ØÎĵµ£º

º½¿Õ¹«Ë¾¹ÜÀíϵͳ(VC++ ÓëSQL 2005)

ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
      ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......

sql server³£ÓÃÓï¾ä

1¡¢°´Ê±¼äÅÅÐò
select * from tbl_lms_loginhistory  order by loginhistory_logintime desc
2¡¢
  
ÔÚÒ»¸öÊý¾Ý¿âÖÐÊÇÏÂÁеÄÑù×Ó
³µ´Î Éí·ÝÖ¤ºÅ
27 1
27 2
45 1
25 1
45 2
ÏÖÔÚÎÒÏë »ñµÃµÄÊÇ
³µ´Î ³Ë×ø´ÎÊý
25 1
27 3
45 2
ÇëÎÊ£¬ÎÒµÄSQLÓï¾ä¸ÃÔõôд£¿
select ³µ´ ......

ÓÃSQLÓï¾ä´Óaspnet_profile±íÀïÈ¡Óû§µÄProfileÖµ

The aspnet_Profile table contains the following fields: UserId, PropertyNames, PropertyValuesString, PropertyValuesBinary,  and LastUpdatedDate. The PropertyNames field contains a string delimited with colons (:) that identify which profile fields are stored, what their datatype is and their of ......

Oracle PL/SQL±à³Ì¹æ·¶Ö¸ÄÏ

Ò»¡¢PL/SQL±à³Ì¹æ·¶Ö®´óСд
¾ÍÏñÔÚSQLÖÐÒ»Ñù£¬PL / SQLÖÐÊDz»Çø·Ö´óСдµÄ¡£ÆäÒ»°ã×¼ÔòÈçÏ£º
¹Ø¼ü×Ö(BEGIN, EXCEPTION, END, IF THEN ELSE,LOOP, END LOOP)¡¢Êý¾ÝÀàÐÍ(VARCHAR2, NUMBER)¡¢ÄÚ²¿º¯Êý(LEAST, SUBSTR)ºÍÓû§¶¨ÒåµÄ×Ó³ÌÐò(procedures, functions,packages)£¬Ê¹Óôóд¡£
±äÁ¿ÃûÒÔ¼°SQLÖеÄÁÐÃûºÍ±íÃû£¬Ê¹ÓÃÐ ......

sqlÖÐ in ¡¢not in ¡¢exists¡¢not exists Ó÷¨ºÍ²î±ð

exists £¨sql ·µ»Ø½á¹û¼¯ÎªÕ棩
not exists (sql ²»·µ»Ø½á¹û¼¯ÎªÕ棩
ÈçÏ£º
±íA
ID NAME
1    A1
2    A2
3  A3
±íB
ID AID NAME
1    1 B1
2    2 B2
3    2 B3
±íAºÍ±íBÊÇ£±¶Ô¶àµÄ¹Øϵ A.ID => B.AID
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ