¹ØÓÚSQLÓï¾äµÄ×Ô¶¯Éú³É
ÔÚÎÒÃǵÄÈÕ³£±à³ÌÖУ¬Êý¾Ý¿âµÄ³ÌÐò»ù±¾É϶¼ÒªÓëSQLÓï¾ä´ò½»µÀ£¬SQLÓï¾äµÄ±àд²»¿É±ÜÃâµÄ³ÉΪһ¸öÍ·Ì۵Ť×÷¡£ÇÒÒòΪSQLÓï¾äÊÇSTRINGÀàÐÍ£¬Òò´ËÔÚ±àÒë½×¶Î²é²»³ö´í£¬Ö»Óе½ÔËÐÐʱ²ÅÄÜ·¢ÏÖ´íÎó¡£
±¾ÎĵĽâ¾ö·½°¸£¬Í¨¹ý×Ô¶¯Éú³ÉSQLÓï¾ä£¬ÔÚÒ»¶¨³Ì¶ÈÉϽµµÍ³ö´íµÄ¸ÅÂÊ£¬´Ó¶øÌá¸ß±à³ÌЧÂÊ¡£ public interface IClause
{
void Add(string name, object val);
void AddWhere(string name, object val);
void Clear();
string TableName { set;}
} Ê×ÏȳéÏó³öÉú³ÉÆ÷µÄ±ê×¼½Ó¿Ú£¬Add¼°Addwhere,·Ö±ðÓÃÔö¼Ó×ֶμ°WHEREÌõ¼þµÄ£¬ ±ÈÈç˵£¬ÔÚInsert״̬Ï£¬Add("name","gates")Ï൱ÓÚ×Ö¶ÎnameµÄֵΪgates ÔÚselect״̬Ï£¬Add("name","gates")Ï൱ÓÚ×Ö¶ÎnameµÄ±ðÃûΪgates¼´select name as gates ÔÚupdate״̬Ï£¬Add("name","gates")Ï൱ÓÚ×Ö¶ÎnameµÄֵΪgates¼´update name = "gates" TableNameÊôÐÔ¼´²Ù×÷µÄ±íÃû Clear()ÊÇΪÁËÒ»¸öʵÀý¶à´ÎÓ¦Óã¬Çå¿Õµ±Ç°µÄ×ֶμ°WHEREÌõ¼þ£¬±íÃûµÄÉèÖö¼Í¨¹ýTABLENAMEÊôÐÔÉèÖà »ùÀàʵÏÖ½Ó¿Ú£¬Í¨¹ý»ùÀàµÄʵÏÖ£¬´Ó¶øÓÐЧµÄʵÏֵĴúÂëÆÁ±Î¡£ 1 private abstract class BaseClause : IClause 2 ...{ 3 private string m_strTable = string.Empty; 4
Ïà¹ØÎĵµ£º
UNION ÔËËã·û½«¶à¸ö SELECT Óï¾äµÄ½á¹û×éºÏ³ÉÒ»¸ö½á¹û¼¯¡£ £¨£±£©Ê¹Óà UNION ÐëÂú×ãÒÔÏÂÌõ¼þ£º £Á£ºËùÓвéѯÖбØÐë¾ßÓÐÏàͬµÄ½á¹¹£¨¼´²éѯÖеĵÄÁÐÊýºÍÁеÄ˳Ðò±ØÐëÏàͬ£©¡£ £Â£º¶ÔÓ¦ÁеÄÊý¾ÝÀàÐÍ¿ÉÒÔ²»Í¬µ«ÊDZØÐë¼æÈÝ£¨ËùνµÄ¼æÈÝÊÇÖ¸Á½ÖÖÀàÐÍÖ®¼ä¿ÉÒÔ½øÐÐÒþʽת»»£¬²»ÄܽøÐÐÒþʽת»»Ôò±¨´í£©¡£Ò²¿ÉÒÔÓÃÏÔʽת»»ÎªÏàͬµ ......
ÏÂÔصØÖ·£º 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" ......
int object_id('objectname');
´Ë·½·¨·µ»ØÊý¾Ý¿â¶ÔÏó±êʶºÅ¡£
ÆäÖУ¬²ÎÊýobjectname ±íʾҪʹÓõĶÔÏó£¬ÆäÊý¾ÝÀàÐÍΪnchar»òchar£¨Èç¹ûΪchar£¬ÏµÍ³½«Æäת»»Îªnchar£©
·µ»ØÀàÐÍΪint£¬±íʾ¸Ã¶ÔÏóÔÚϵͳÖеıàºÅ¡£
±ÈÈ磺
use wf_timesheet
select object_id('usp_check_excess_hours')
·µ»ØΪ197575742¡£
´Ë· ......
CLR¿ÉÒÔʵÏÖDMLºÍDDLÁ½ÖÖ´¥·¢ÐÎʽ£¬µ«ÊDZ¾ÈËÒ»°ã²»½¨ÒéʹÓÃCLRµÄ´¥·¢Æ÷£¬Ö÷ÒªÊÇ¿¼Âǵ½Ð§ÂÊÎÊÌâ¡£±ÈÈçÎÒÃÇʹÓÃtriggerÀ´ÊµÏÖ·¢mailµÈ²Ù×÷ʱ£¬¾ÍÒª¿¼ÂÇpop3»òÊÇsmtpµÈ´ýʱ¼ä£¬ÒòΪtrigger±¾Ê¾ÍÊǸöÊÂÎñ£¬Ò²¾ÍÊÇ˵£¬ÔÚsmtpµÈ´ýʱ¼äÒ²ËãÔÚÁËÕû¸öÊÂÎñÖУ¬ÕâÑù¾Í»á´ó´óÓ°ÏìЧÂÊ¡£
1.CLR DML´¥·¢Æ÷
DMLÖ¸µÄÊÇÊý¾Ý²Ù×÷ÓïÑÔ£¬Ò²¾Í ......
1£¬SqlServer´æ´¢¹ý³ÌµÄÊÂÎñ´¦Àí
Ò»ÖֱȽÏͨÓõijö´í´¦ÀíµÄģʽ´ó¸ÅÈçÏ£º
Create procdure prInsertProducts
(
@intProductId int,
@chvProductName varchar(30),
@intProductCount int
)
AS
Declare @intErrorCode int
Select @intErrorCode=@@Error
Begin transaction
if @intError ......