ÓÐÕâÑùÒ»¸ö×Ö·û´®(ÖÐ,¹ú,ÖÐ,ÈËÃñ,¹ú,ÏÖ´ú¹¤Òµ»¯½ø³Ì,¹ú)
´¦Àí¹ýÖ®ºó±ä³É(ÖÐ,¹ú,ÈËÃñ,ÏÖ´ú¹¤Òµ»¯½ø³Ì)
ÒÔÏÂÊÇÎҵķ½·¨,ÓÐʲô²»¶ÔµÄµØ·½»¹Çë¸÷λָµã
------------------ɾ³ýÖظ´µÄ×Ö·û
declare
@v1 nvarchar
(100)
declare
@v2 nvarchar
(100)
declare
@v3 nvarchar
(100)
declare
@split nvarchar
(100)
--N',,,,,ÖÐ,¹ú,ÖÐ,ÈËÃñ,,,,,¹ú,ÏÖ´ú¹¤Òµ»¯½ø³Ì,¹ú,,,'
set
@v1=N', ,, ,,ÖÐ,¹ú,ÖÐ,ÈËÃñ, ,, , ,¹ú,ÏÖ´ú¹¤Òµ»¯½ø³Ì,¹ú, ,,'
set
@v3=''
set
@split=','
/*
@v1 :´æ´¢ÁÙʱ×Ö·û´®
@v2 :»ñÈ¡Á½¸ö·Ö¸ô·ûÖеÄ×Ö·û´®
@v3 :´æ´¢×îºóûÓÐÖظ´µÄ×Ö·û´®
*/
if
left(@v1,1)<>@split
set
@v1=@split+@v1
if
right(@v1,1)<>@split
set
@v1=@v1+@split
while
len(@v1)>len(@split)*2
begin
set
@v2=substring
(@v1,len( @split),charindex
( @split,@v1,len
( @split)+1))
if
len(@v2)>len
(@split)*2
begin
set
@v2=right
(@v2,len(@v2)-1);
if
ltrim
(rtrim
(@v2))<>@split
set
@v3=@v3+ltrim
(rtrim
(@v2));
set
@v1= replace
(@v1,@v2,'')
end
else
--Èç¹ûÓÐÁ¬ÐøµÄ·Ö¸î·û,ɾ
from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í£¬driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom×Ó¾äÖаüº¬¶à¸ö±íµÄÇé¿öÏ£¬Äã±ØÐëÑ¡Ôñ¼Ç¼ÌõÊý×îÉٵıí×÷Ϊ»ù´¡±í¡£
¡¡¡¡Ìá¸ßSQLÖ´ÐÐЧÂʵļ¸µã½¨Òé:
¡¡¡¡¡ô¾¡Á¿²»ÒªÔÚwhereÖаüº¬×Ó²éѯ;
¡¡¡¡¹ØÓÚʱ¼äµÄ²éѯ£¬¾¡Á¿²»ÒªÐ´³É£ºwhere to_char(dif_date,'yyyy-mm-dd')=to_char('2007-07-01',' ......