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");
Ïà¹ØÎĵµ£º
from:csdn
ÄÜ·ñÀûÓô¥·¢Æ÷²Ù×÷Ô¶³ÌÊý¾Ý¿â?
------------------------------------------------------------
-----01
------------------------------------------------------------
ÄÜ/********************Á´½ÓÊý¾Ý¿â *******************************/
exec OPENDA ......
UNION ÔËËã·û½«¶à¸ö SELECT Óï¾äµÄ½á¹û×éºÏ³ÉÒ»¸ö½á¹û¼¯¡£ £¨£±£©Ê¹Óà UNION ÐëÂú×ãÒÔÏÂÌõ¼þ£º £Á£ºËùÓвéѯÖбØÐë¾ßÓÐÏàͬµÄ½á¹¹£¨¼´²éѯÖеĵÄÁÐÊýºÍÁеÄ˳Ðò±ØÐëÏàͬ£©¡£ £Â£º¶ÔÓ¦ÁеÄÊý¾ÝÀàÐÍ¿ÉÒÔ²»Í¬µ«ÊDZØÐë¼æÈÝ£¨ËùνµÄ¼æÈÝÊÇÖ¸Á½ÖÖÀàÐÍÖ®¼ä¿ÉÒÔ½øÐÐÒþʽת»»£¬²»ÄܽøÐÐÒþʽת»»Ôò±¨´í£©¡£Ò²¿ÉÒÔÓÃÏÔʽת»»ÎªÏàͬµ ......
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 @ ......
int object_id('objectname');
´Ë·½·¨·µ»ØÊý¾Ý¿â¶ÔÏó±êʶºÅ¡£
ÆäÖУ¬²ÎÊýobjectname ±íʾҪʹÓõĶÔÏó£¬ÆäÊý¾ÝÀàÐÍΪnchar»òchar£¨Èç¹ûΪchar£¬ÏµÍ³½«Æäת»»Îªnchar£©
·µ»ØÀàÐÍΪint£¬±íʾ¸Ã¶ÔÏóÔÚϵͳÖеıàºÅ¡£
±ÈÈ磺
use wf_timesheet
select object_id('usp_check_excess_hours')
·µ»ØΪ197575742¡£
´Ë· ......
ÒòÏÖÔڵŤ×÷ÐèÒª£¬
ÎҵôÓWinFormµÄƽ̨£¬
תÐ͵½WebFormµÄÒ³Ãæ¡£
ÓÐÒ»Äê¶àûÓнӴ¥SQL ServerÁË£¬
ËäÈ»´óѧʱÓеã»ù´¡£¬
µ«Ò²Íü¼ÇµÃ²î²»¶àÁË¡£
ÒòΪAsp.netÐ͵ÄB/SÍøÕ¾ºÍWinFormµÄ»¹ÊÇÓе㲻ͬ£¬
ÏÖÔÚ¹¤×÷ÆðÀ´²»ÊÇÄÇôµÃÐÄÓ¦ÊÖ¡£
ιʶø֪У¬
¾Í°ÑÒÔǰʵϰʱ×öµÄµÄÍøÕ¾Ô´´úÂëÄóöÀ´¿´¿´¡£
ÒòΪҪÓõ½SQL 2005S ......