SQLÈçºÎÓÅ»¯ÎÊÌâ - MS-SQL Server / ÒÉÄÑÎÊÌâ
½ñÌì×öÁËÒ»¸ö´æ´¢¹ý³Ì »·¾³ÊÇSQL2000Êý¾Ý¿â
´óÖÂÈçÏÂ
½¨Á¢ÁÙʱ±í
¶¨ÒåÔ±¹¤Óαê
Ñ»·Ô±¹¤£¨ÊôÓÚ1¸ö¹«Ë¾)
¶¨Ò幫˾¹¤×ÊÏîÄ¿Óαê
Ñ»·¸Ã¹«Ë¾¹¤×ÊÏîÄ¿(ÓÐ50¸ö×óÓÒ¹¤×ÊÏîÄ¿)
£¨ÓÐЩ¿ÉÒÔÖ±½Ó´Ó¹¤×ʱíÀïÃæÖ±½ÓÈ¡³öÀ´ ±ÈÈçÌõ¼þÊǹ¤×ÊÏîÄ¿±àºÅ=2
µ«ÊÇÓÐЩ²»ÄÜÖ±½ÓÈ¡ ±ÈÈ繤×ÊÏîÄ¿±àºÅ2+ ¹¤×ʱàºÅ3µÈµÈ
¼ÆËãÁ¿¿ÉÄܱȽϴó ÕâÀïµÄSQL¶¼ÊǶ¯Ì¬Éú³É³öÀ´µÄ£©
ÿ´ÎÓÃexec sp_executesql ¼ÆËã½á¹û
½áÊøÑ»·¸Ã¹«Ë¾
Ïà¹ØÎÊ´ð£º
±íÈçÏÂ
½ÌÊÒID ×ùλÊý ¿ªÊ¼Ê±¼ä ½áÊøʱ¼ä 2009Äê1ÔÂ1ÈÕ 2009Äê1ÔÂ2ÈÕ 2009Äê1ÔÂ3ÈÕ
101 50 08£º00 08£º30 30 40 50
101 50 09£º00 ......
ÇëÎÊһϣ¬ÍâÍøÁ½Ì¨SQLSERVERʵÀýÊý¾Ý´«Ê䣬ÓÐûÓвÉÓÃÊý¾ÝѹËõºÍ¼ÓÃÜ¡£Ñ¹Ëõ±ÈÊǶàÉÙ£¬¼ÓÃÜÊÇʲô¼ÓÃÜËã·¨£¿Ïà¹ØÎĵµÄÄÀï¿ÉÒÔÕÒµ½£¿Ð»Ð»
ÎÒÒ²ÏëÖªµÀ£¡¹Ø×¢´ËÌù£¡
¹Ø×¢¡«¡«
Êý¾Ý¿â´óÅ£¶¼ÄÄÈ¥ÁË°¡£¿
......
ÎÒµÄTblworkbill±íµÄÊý¾ÝÈçÏÂ:
id workbillno ..................
1 1
2 6
3 a1
4 c2
5 2
6 aa
7 ......
ÎÒÒªµÃµ½Ò»¸ö×Ö·û´®È磺
sdfk|||sgts
sdfsfd|||rgreg
wrfw|||sefw
¾ÍÊÇÒªµÃµ½|||ºóÃæµÄ×Ö·û´®£¬ÓÐʲôº¯ÊýÂð£¿ÔõôÓÃÄØ£¿Ð»Ð»£¡
SQL code:
select
right(col,len(col)-charindex('|||',col)-2)
f ......
sql 2005Êý¾Ý¿âÎÒÏëµÃµ½Ò»×Ö·û´®Îª:
sldkf|||sdeww
erkv|||rltdk
jemcl|||ligf
¾ÍÊÇ|||ºóÃæµÄ×Ö·ûÓÐʲôº¯ÊýÄܵõ½Âð£¿ÊÇÔÚsqlÓï¾äдµÄ£¬²»ÊÇÔÚÒ³ÃæдµÄ£¬ÄÇλ¸ßÊÖÀ´Ö¸½ÌÏ£¬ÐÂÊÖ£¬Ð»Ð»
ÔÎ µ ......