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

SQL Server CLRÈ«¹¦ÂÔÖ®ËÄ

CLR¿ÉÒÔʵÏÖDMLºÍDDLÁ½ÖÖ´¥·¢ÐÎʽ£¬µ«ÊDZ¾ÈËÒ»°ã²»½¨ÒéʹÓÃCLRµÄ´¥·¢Æ÷£¬Ö÷ÒªÊÇ¿¼Âǵ½Ð§ÂÊÎÊÌâ¡£±ÈÈçÎÒÃÇʹÓÃtriggerÀ´ÊµÏÖ·¢mailµÈ²Ù×÷ʱ£¬¾ÍÒª¿¼ÂÇpop3»òÊÇsmtpµÈ´ýʱ¼ä£¬ÒòΪtrigger±¾Ê¾ÍÊǸöÊÂÎñ£¬Ò²¾ÍÊÇ˵£¬ÔÚsmtpµÈ´ýʱ¼äÒ²ËãÔÚÁËÕû¸öÊÂÎñÖУ¬ÕâÑù¾Í»á´ó´óÓ°ÏìЧÂÊ¡£
1.CLR DML´¥·¢Æ÷
DMLÖ¸µÄÊÇÊý¾Ý²Ù×÷ÓïÑÔ£¬Ò²¾ÍÊÇͨ³£µÄinsert,updateºÍdelete²Ù×÷¡£Õâ¸ö´¥·¢Æ÷Ö÷ҪʵÏÖÔÚ¶ÔpubsÊý¾Ý¿âÖеÄauthor±í½øÐÐinsert,update,deleteʱ£¬»áÏÔʾÏàÓ¦µÄ²Ù×÷Ãû³Æ¡£
///
    /// °Ñinsert,update,delete²Ù×÷¶¼ÏÔʾ³öÀ´
    ///
    [Microsoft.SqlServer.Server.SqlTrigger(
        Name = "UF_DML_Trigger",
        Target = "dbo.authors",
        Event = "FOR INSERT, UPDATE, DELETE")]
    public static void UF_DML_Trigger()
    {
        switch (SqlContext.TriggerContext.TriggerAction)
        {
            case TriggerAction.Insert:
                SqlContext.Pipe.Send("Trigger Insert");
                break;
            case TriggerAction.Update:
                SqlContext.Pipe.Send("Trigger Update");
                break;
            case TriggerAction.Delete:
                SqlContext.Pipe.Send("Trigger Delete");
              


Ïà¹ØÎĵµ£º

SQL ÖÐGROUP BY ×ܽá

GROUP BY ×Ó¾äÓÃÀ´¶ÔÖ¸¶¨µÄ×Ö¶Î×ö·Ö×飬²úÉúÒ»¸ö»ã×ÜÐÅÏ¢¡£ £¨1£©group byÓï¾ä¶ÔselectºóËùÑ¡ÔñµÄ×Ö¶ÎÓÐÒ»¶¨µÄÏÞÖÆ£¬¼´selectºóûÓÐʹÓþۺϺ¯ÊýµÄ×ֶαØÐë°üº¬ÔÚgroup by Óï¾äºóÃæµÄ½á¹û¼¯ÖС££¨GROUP BY ¹Ø¼ü×Öºó¸úÒ»¸öÁеÄÁÐ±í£¬³ÆΪ×éºÏÁУ©. £¨2£©²»ÄܶÔÊý¾ÝÀàÐÍΪ ntext¡¢text¡¢image »ò bit µÄÁÐʹÓà GROUP BY »ò ......

¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨


SQL code
¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨
1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ
eg: Select * from tableName
Exec('select * from tableName')
Exec sp_executesql N'select * from tableName' -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
eg:
declare @ ......

SQLÓÅ»¯¹ý³ÌÖг£¼ûOracle HINTµÄÓ÷¨

 ÔÚSQLÓï¾äÓÅ»¯¹ý³ÌÖУ¬ÎÒÃǾ­³£»áÓõ½hint,ÏÖ×ܽáÒ»ÏÂÔÚSQLÓÅ»¯¹ý³ÌÖг£¼ûOracle HINTµÄÓ÷¨£º
1. /*+ALL_ROWS*/
±íÃ÷¶ÔÓï¾ä¿éÑ¡Ôñ»ùÓÚ¿ªÏúµÄÓÅ»¯·½·¨,²¢»ñµÃ×î¼ÑÍÌÍÂÁ¿,ʹ×ÊÔ´ÏûºÄ×îС»¯.
ÀýÈç:
SELECT /*+ALL+_ROWS*/ EMP_NO,EMP_NAM,DAT_IN from BSEMPMS WHERE EMP_NO='SCOTT';
2. /*+FIRST_ROWS*/
±í ......

SQLʹÓÃ

Êý¾Ý´¦ÀíÊǵ±Ç°Êý¾Ý¿â³£¼ûµÄÓ¦Óá£Ò»Ð©Êý¾Ý¿â×é³ÉDATA mart´ÓÊý¾ÝÔ´Àï³éÈ¡¹ØÐĵıí½øÐоۺϣ¬½«½á¹ûÍÆË͵½Ëã·¨ÖнøÐд¦Àí£¬´Ó¶ø¸ßÐÔÄܵĻشðÓû§µÄ²éѯ¡£
×ÜËùÖÜÖª£¬LogÎļþÊǼǼÊý¾Ý¿â²Ù×÷µÄÎļþ£¬¶ÔÊý¾Ý¿âµÄÍêÕûÐÔ£¬Ò»ÖÂÐÔÓÐ×ÅÖØÒªµÄÒâÒå¡£×÷ΪÊý¾Ý´¦ÀíµÄÒ»¸ö³£¼ûºó¹ûÊÇLogÎļþµÄ³¬¼¶ÅÓ´ó¡£ËäÈ»½«Êý¾Ý¿âµÄ»Ö¸´Ä£Ê½ÉèÖó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ