ÓÐÕâÑùÒ»¸ö×Ö·û´®(ÖÐ,¹ú,ÖÐ,ÈËÃñ,¹ú,ÏÖ´ú¹¤Òµ»¯½ø³Ì,¹ú)
´¦Àí¹ýÖ®ºó±ä³É(ÖÐ,¹ú,ÈËÃñ,ÏÖ´ú¹¤Òµ»¯½ø³Ì)
ÒÔÏÂÊÇÎҵķ½·¨,ÓÐʲô²»¶ÔµÄµØ·½»¹Çë¸÷λָµã
------------------ɾ³ýÖظ´µÄ×Ö·û
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
--Èç¹ûÓÐÁ¬ÐøµÄ·Ö¸î·û,ɾ
½ñÌìÔÚÂÛ̳ÄÚ¿´µ½Ò»Æª ÃæÊÔÌ⣬ÊǹØÓÚwhere ºÍon µÄÇø±ðµÄ£¬×Ô¼ºÒ²²»¶®£¬ÔÚÍøÉÏËѳöһƪÎÄÕ£¬¼ÓÉî×Ô¼ºµÄ¼ÇÒä
ת
Êý¾Ý¿âÔÚͨ¹ýÁ¬½ÓÁ½ÕÅ»ò¶àÕűíÀ´·µ»Ø¼Ç¼ʱ£¬¶¼»áÉú³ÉÒ»ÕÅÖмäµÄÁÙʱ±í£¬È»ºóÔÙ½«ÕâÕÅÁÙʱ±í·µ»Ø¸øÓû§¡£
ÔÚʹÓÃleft jionʱ£¬onºÍwhereÌõ¼þµÄÇø±ðÈçÏ£º
1¡¢ onÌõ¼þ ......