SQLÁ÷Ë®ÕʺŵÄÉú³É
1 --ÏÂÃæµÄ´úÂëÉú³É³¤¶ÈΪ8µÄ±àºÅ£¬±àºÅÒÔBH¿ªÍ·£¬ÆäÓà6λΪÁ÷Ë®ºÅ¡£
2 --µÃµ½Ð±àºÅµÄº¯Êý
3 CREATE FUNCTION f_NextBH()
4 RETURNS char(8)
5 AS
6 BEGIN
7 RETURN(SELECT 'BH'+RIGHT(1000001+ISNULL(RIGHT(MAX(BH),6),0),6) from tb WITH(XLOCK,PAGLOCK))
8 END
9 GO
10
11 --ÔÚ±íÖÐÓ¦Óú¯Êý
12 CREATE TABLE tb(
13 BH char(8) PRIMARY KEY DEFAULT dbo.f_NextBH(),
14 col int)
15
16 --²åÈë×ÊÁÏ
17 BEGIN TRAN
18 INSERT tb(col) VALUES(1)
19 INSERT tb(col) VALUES(2)
20 INSERT tb(col) VALUES(3)
21 DELETE tb WHERE col=3
22 INSERT tb(col) VALUES(4)
23 INSERT tb(BH,col) VALUES(dbo.f_NextBH(),14)
24 COMMIT TRAN
25
26 --ÏÔʾ½á¹û
27 SELECT * from tb
28 /*--½á¹û
29 BH col
30 ---------------- -----------
31 BH000001 1
32 BH000002 2
33 BH000003 4
34 BH000004 14
35 --*/
Ïà¹ØÎĵµ£º
°´Ö¸¶¨´ÎÊýÖظ´×Ö·û±í´ïʽ¡£
Óï·¨
REPLICATE ( character_expression, integer_expression)
²ÎÊý
character_expression
×Ö·ûÊý¾ÝÐ͵Ä×ÖĸÊý×Ö±í´ïʽ£¬»òÕß¿ÉÒÔÒþʽת»»Îª nvarchar »ò ntext µÄÆäËûÊý¾ÝÀàÐ͵Ä×ÖĸÊý×Ö±í´ïʽ¡£
integer_expression
¿ÉÒÔÒþʽת»»Îª int µÄ±í´ïʽ¡£Èç¹û integer_expression Ϊ ......
Ëæ×ÅB/SģʽӦÓÿª·¢µÄ·¢Õ¹£¬Ê¹ÓÃÕâÖÖģʽ±àдӦÓóÌÐòµÄ³ÌÐòÔ±Ò²Ô½À´Ô½¶à¡£µ«ÊÇÓÉÓÚ³ÌÐòÔ±µÄˮƽ¼°¾ÑéÒ²²Î²î²»Æ룬Ï൱´óÒ»²¿·Ö³ÌÐòÔ±ÔÚ±àд´úÂëµÄʱºò£¬Ã»ÓжÔÓû§ÊäÈëÊý¾ÝµÄºÏ·¨ÐÔ½øÐÐÅжϣ¬Ê¹Ó¦ÓóÌÐò´æÔÚ°²È«Òþ»¼¡£Óû§¿ÉÒÔÌá½»Ò»¶ÎÊý¾Ý¿â²éѯ´úÂ룬¸ù¾Ý³ÌÐò·µ»ØµÄ½á¹û£¬»ñµÃijЩËûÏëµÃÖªµÄÊý¾Ý£¬Õâ¾ÍÊÇËùνµÄSQL Inj ......
Îå¡¢ÉÏ´«ASPľÂí
ËùνASPľÂí£¬¾ÍÊÇÒ»¶ÎÓÐÌØÊ⹦ÄܵÄASP´úÂ룬²¢·ÅÈëWEBÐéÄâĿ¼µÄScriptsÏ£¬Ô¶³Ì¿Í»§Í¨¹ýIE¾Í¿ÉÖ´ÐÐËü£¬½ø¶øµÃµ½ÏµÍ³µÄUSERȨÏÞ£¬ÊµÏÖ¶ÔϵͳµÄ³õ²½¿ØÖÆ¡£ÉÏ´«ASPľÂíÒ»°ãÓÐÁ½ÖֱȽÏÓÐЧµÄ·½·¨£º
1¡¢ÀûÓÃWEBµÄÔ¶³Ì¹ÜÀí¹¦ÄÜ
  ......
ÎÒÃÇÒª×öµ½²»µ«»áдSQL,»¹Òª×öµ½Ð´³öÐÔÄÜÓÅÁ¼µÄSQL,ÒÔÏÂΪ±ÊÕßѧϰ¡¢ÕªÂ¼¡¢²¢»ã×ܲ¿·Ö×ÊÁÏÓë´ó¼Ò·ÖÏí£¡
£¨1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLE µÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom× ......
varcharºÍnvarcharÈçºÎÑ¡Ôñ£º
varcharÔÚSQL ServerÖÐÊDzÉÓõ¥×Ö½ÚÀ´´æ´¢Êý¾ÝµÄ£¬nvarcharÊÇʹÓÃUnicoÀ´´æ´¢Êý¾ÝµÄ¡£ÖÐÎÄ×Ö·û´æ´¢µ½SQL ServerÖлᱣ´æΪÁ½¸ö×Ö½Ú£¨Ò»°ã²ÉÓÃUnico±àÂ룩£¬Ó¢ÎÄ×Ö·û±£´æµ½Êý¾Ý¿âÖУ¬Èç¹û×ֶεÄÀàÐÍΪvarchar£¬ÔòÖ»»áÕ¼ÓÃÒ»¸ö×Ö½Ú£¬¶øÈç¹û×ֶεÄÀàÐÍΪnvarchar£¬Ôò»áÕ¼ÓÃÁ½¸ö×Ö½Ú¡£ËäȻʹÓÃnva ......