Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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Ô¶³Ì·þÎñÆ÷£¬Í¬²½Êý¾Ý´¥·¢Æ÷


from:csdn
ÄÜ·ñÀûÓô¥·¢Æ÷²Ù×÷Ô¶³ÌÊý¾Ý¿â?
------------------------------------------------------------
-----01
------------------------------------------------------------
ÄÜ/********************Á´½ÓÊý¾Ý¿â   *******************************/  
  exec   OPENDA ......

ÀûÓÃÕýÔò±í´ïʽʵÏֵļòµ¥µÄÕûÀíSQLÎı¾µÄС¹¤¾ß

ÏÂÔØµØÖ·£º http://download.csdn.net/source/1805903
  private string ReArrange(string str)
{
string[] keywords = new string[] {"select","from","where","and","order\\s+by","or","into",
"update","set","delete","haveing" ......

SQLÖÐobject_idº¯ÊýµÄÓ÷¨

 int object_id('objectname');
´Ë·½·¨·µ»ØÊý¾Ý¿â¶ÔÏó±êʶºÅ¡£
ÆäÖУ¬²ÎÊýobjectname ±íʾҪʹÓõĶÔÏ󣬯äÊý¾ÝÀàÐÍΪnchar»òchar£¨Èç¹ûΪchar£¬ÏµÍ³½«Æäת»»Îªnchar£©
·µ»ØÀàÐÍΪint£¬±íʾ¸Ã¶ÔÏóÔÚϵͳÖеıàºÅ¡£
±ÈÈ磺
use wf_timesheet
select object_id('usp_check_excess_hours')
·µ»ØÎª197575742¡£
´Ë· ......

ÐÞ¸ÄSQLÊý¾Ý¿âµÄÃû³Æ


ÆäʵÔÚÐÞ¸ÄÊý¾Ý¿âÃû³ÆÖ®Ç°£¬Èç¹ûÓÐÓû§Á¬½Óµ½Êý¾Ý¿âµÄ»°»áÔì³ÉÊý¾Ý¿âÖØÃüÃûʧ°Ü£¬¿ÉÒÔÏÈÖ´ÐÐ
select spid
from master.dbo.sysprocesses
where dbid=db_id('OldDbName')
½á¹û¼¯ÖÐÏÔʾµÄÊǵ±Ç°Á¬½Óµ½Êý¾Ý¿âOldDbNameµÄÁ¬½Ó
±ÈÈç½á¹ûÊÇ
79
81
µ±È»£¬Êµ¼ÊÖµÓ¦¸Ã²»ÊÇÕâÁ½¸ö
È»ºóÖ´ÐÐ
kill 79
kill 81
¹Ø±ÕÒѽ¨Á¢ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ