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

SQL֮ʮ profiler

Microsoft SQL Server Profiler ÊÇ SQL ¸ú×ÙµÄͼÐÎÓû§½çÃ棬ÓÃÓÚ¼àÊÓ Êý¾Ý¿âÒýÇæ»ò Analysis Services µÄʵÀý¡£Äú¿ÉÒÔ²¶»ñÓйØÿ¸öʼþµÄÊý¾Ý²¢½«Æä±£´æµ½Îļþ»ò±íÖй©ÒÔºó·ÖÎö¡£ÀýÈ磬¿ÉÒÔ¶ÔÉú²ú»·¾³½øÐмàÊÓ£¬Á˽âÄÄЩ´æ´¢¹ý³ÌÓÉÓÚÖ´ÐÐËÙ¶ÈÌ«ÂýÓ°ÏìÁËÐÔÄÜ¡£
¿ÉÒÔʹÓà SQL Server ProfilerÀ´´´½¨Ä£°å£¬¶¨ÒåÒª°üº¬ÔÚ¸ú×ÙÖеÄʼþÀàºÍÊý¾ÝÁС£¶¨Òå²¢±£´æÄ£°åºó£¬¿ÉÒÔÔËÐиú×ÙÀ´¼Ç¼ÿ¸öÑ¡¶¨Ê¼þÀàµÄÊý¾Ý¡£Äú¿ÉÒÔ½«Ò»¸öÄ£°åÓÃÓÚ¶à¸ö¸ú×Ù£»Ä£°å±¾Éí²¢²»»áÖ´ÐС£
SQL Server Profiler¿ÉÏÔʾ SQL Server ÈçºÎÔÚÄÚ²¿½âÎö²éѯ¡£Õâ¾Íʹ¹ÜÀíÔ±Äܹ»×¼È·²é¿´Ìá½»µ½·þÎñÆ÷µÄ Transact-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  & ......

SQL²âÊÔ ½»¼¯¡¢²¢¼¯¡¢²î¼¯¡¢µÑ¿¨¶û»ý

²¢¼¯:
ʹÓà UNION ÔËËã·û×éºÏ¶à¸ö½á¹û
SELECT name,num from Table1
UNION
SELECT name,num from Table2
×¢Ò⣺²éѯµÄ×ֶθöÊý±ØÐëÏàͬ£¬Table2µÄ×Ö¶ÎÀàÐÍÒª¸úTable1µÄÏàͬ.
Èç¹ûʹÓà UNION ÔËËã·û£¬ÄÇôµ¥¶ÀµÄ SELECT Óï¾ä²»ÄÜ°üº¬Æä×Ô¼ºµÄ ORDER BY »ò COMPUTE ×Ӿ䡣ֻÄÜÔÚ×îºóÒ»¸ö SELECT Óï¾äµÄºóÃæʹÓÃÒ»¸ö ORD ......

SQL ÖÐWith as µÄÓ÷¨

Ò»£®WITH ASµÄº¬Òå
WITH AS¶ÌÓҲ½Ð×ö×Ó²éѯ²¿·Ö£¨subquery factoring£©£¬¿ÉÒÔÈÃÄã×öºÜ¶àÊÂÇ飬¶¨ÒåÒ»¸öSQLƬ¶Ï£¬¸ÃSQLƬ¶Ï»á±»Õû¸öSQLÓï¾äËùÓõ½¡£ÓеÄʱºò£¬ÊÇΪÁËÈÃSQLÓï¾äµÄ¿É¶ÁÐÔ¸ü¸ßЩ£¬Ò²ÓпÉÄÜÊÇÔÚUNION ALLµÄ²»Í¬²¿·Ö£¬×÷ΪÌṩÊý¾ÝµÄ²¿·Ö¡£
Ìرð¶ÔÓÚUNION ALL±È½ÏÓÐÓá£ÒòΪUNION ALLµÄÿ¸ö²¿·Ö¿ÉÄÜÏàͬ£¬µ ......

Êý¾Ý¿â×é¼þ Hxj.Data £¨Ê®£© £¨Êä³ö×é¼þÖ´ÐеÄsql£©

Ç°ÃæÓÐTXÁôÑÔÎÊ·ÖÒ³µÄsqlÊÇÔõôÑùµÄ£¬¿´ÍêÕâƪÄãÒ²¾ÍÖªµÀÁË¡£ ×é¼þ¿ÉÒÔÊä³öÖ´ÐеÄsql£¬·½±ã²é¿´sqlÉú³ÉµÄÓï¾äÊÇ·ñÓÐÎÊÌâ¡£ ͨ¹ý×¢²áʼþÀ´Êä³ösql DbSession.Default.RegisterSqlLogger(database_OnLog);
 
private string sql;
void database_OnLog(string logMsg)
{
//±£´æÖ´ÐеÄDbCommand (sqlÓï ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ