³É¼¨µ¥¡¢Òµ¼¨±íSQL(Ò»¸ö×ݱí±äºá±í Ò»¸öÓÿª´°º¯Êý)
Ôʼ±í£º
name course score
-----------------------------------------
ÕÅÈý ÓïÎÄ 80
ÕÅÈý Êýѧ 75
ÕÅÈý ÍâÓï 60
ÀîËÄ ÓïÎÄ 90
ÀîËÄ Êýѧ 85
ÀîËÄ ÍâÓï 70
ÍõÎå ÓïÎÄ 95
ÍõÎå Êýѧ 80
ÍõÎå ÍâÓï 75
½á¹û±í£º
ÐÕÃû ÓïÎÄ Êýѧ ÍâÓï
-----------------------------------------
ÕÅÈý 80 75 60
ÀîËÄ 90 85 70
ÍõÎå 95 80 75
=========================================
Ôʼ±í£º
city volume
---------------------
±±¾© 16000
¶«Ý¸ 5000
ÉϺ£ 200000
¹ãÖÝ 8500
Õ¿½ &
Ïà¹ØÎĵµ£º
ÔÚ·Ö×éÅÅÐò¹ý³ÌÖÐÐèҪн¨ÅÅÐòÁУ¬°´Ìõ¼þ:(ÎïÁÏ·ÖÀà+¿Í»§Ãû³Æ) ½øÐзÖ×é»ã×Ü È»ºó¾Í¸ù¾Ý¸ÃÌõ¼þ½øÐÐÅÅÐò
1.ÐèҪƴ´ÕÁ½ÁÐ ×÷ΪÅÅÐòÁÐ,ÈçÐè¼ÓÈëÌØÊâ×Ö·û.¾Í»á±¨´í.
ÒòΪ±¾Éí¸Ä×ֶξÍÊÇvarcharÀàÐÍ ÐèÒª½«charÀàÐÍ'_' ת»»³Évarchar
2.Æ´´Õ¹ý³ÌÖÐÓпոñÐèҪȥ¿Õ¸ñ
e.g£ºselect (trim(ÎïÁÏ·ÖÀà)+to_char( ......
if exists(select 1 from sysobjects where name='char_index')
drop function char_index
create function char_index(@string varchar(8000),@char varchar(10),@index smallint)
--@string:´ý²éÕÒ×Ö·û´®£¬@index:²éÕÒλÖÃ
returns smallint
as
begin
declare
@i tinyint,--µ±Ç°ÕÒµ½µÚ@i¸ö
  ......
¡¾ÔÎĵØÖ·¡¿Tip/Trick: Guard Against SQL Injection Attacks
¡¾ÔÎÄ·¢±íÈÕÆÚ¡¿ Saturday, September 30, 2006 9:11 AM
SQL×¢Èë¹¥»÷ÊǷdz£ÁîÈËÌÖÑáµÄ°²È«Â©¶´£¬ÊÇËùÓеÄweb¿ª·¢ÈËÔ±£¬²»¹ÜÊÇʲôƽ̨£¬¼¼Êõ£¬»¹ÊÇÊý¾Ý²ã£¬ÐèҪȷÐÅËûÃÇÀí½âºÍ·ÀÖ¹µÄ¶«Î÷¡£²»ÐÒµÄÊÇ£¬¿ª·¢ÈËÔ±ÍùÍù²»¼¯Öл¨µãʱ¼äÔÚÕâÉÏÃ棬ÒÔÖÁËûÃǵÄÓ¦Ó㬠......
MS SQL SERVER 2005È«ÎÄË÷Òýѧϰ±Ê¼ÇÒ»
ÏÈÁ˽âÒ»ÏÂÈ«ÎÄË÷ÒýÊÇÈçºÎ´´½¨ºÍʹÓõÄ
´´½¨È«ÎÄË÷Òý:
ÔÚMS SQL SERVER 2005Àï,È«ÎÄË÷ÒýÊÇÒ»¸öµ¥¶ÀµÄ·þÎñÏî,ĬÈÏÊÇÆô¶¯µÄ,µ«ÊÇûÓÐÔÊÐíÊý¾Ý¿âÆôÓÃÈ«ÎÄË÷Òý,Èç¹ûÒ ......
Ò»¡¢ ¼òµ¥²éѯ
¡¡¡¡¼òµ¥µÄTransact-SQL²éѯֻ°üÀ¨Ñ¡ÔñÁÐ±í¡¢from×Ó¾äºÍWHERE×Ӿ䡣ËüÃÇ·Ö±ð˵Ã÷Ëù²éѯÁС¢²éѯµÄ±í»òÊÓͼ¡¢ÒÔ¼°ËÑË÷Ìõ¼þµÈ¡£
¡¡¡¡ÀýÈ磬ÏÂÃæµÄÓï¾ä²éѯtesttable±íÖÐÐÕÃûΪ“ÕÅÈý”µÄnickname×ֶκÍemail×ֶΡ£
¡¡¡¡SELECT nickname,email
¡¡¡¡from testtable
¡¡¡¡WHERE name='ÕÅÈý'
......