隨筆 - 6  文章 - 129  trackbacks - 0
          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          常用鏈接

          留言簿(14)

          隨筆檔案(6)

          文章分類(467)

          文章檔案(423)

          相冊

          收藏夾(18)

          JAVA

          搜索

          •  

          積分與排名

          • 積分 - 826629
          • 排名 - 49

          最新評論

          閱讀排行榜

          評論排行榜

          /****** Object: Function [dbo].[F_SQLSERVER_SPLIT]   Script Date: 2013-10-30 16:21:46 ******/
          USE [ZBP];
          GO
          SET ANSI_NULLS OFF;
          GO
          SET QUOTED_IDENTIFIER ON;
          GO
          CREATE FUNCTION [dbo].[F_SQLSERVER_SPLIT](@Long_str varchar(8000),@split_str varchar(100))    
          RETURNS  @tmp TABLE(        
              ID          inT     IDENTITY PRIMARY KEY,      
              short_str   varchar(8000)    
          )    
          AS   
          BEGIN   
              DECLARE @long_str_Tmp varchar(8000),@short_str varchar(8000),@split_str_length int   
              SET @split_str_length = LEN(@split_str)    
              IF CHARINDEX(@split_str,@Long_str)=1 
                   SET @long_str_Tmp=SUBSTRING(@Long_str,@split_str_length+1,LEN(@Long_str)-@split_str_length)
              ELSE
                   SET @long_str_Tmp=@Long_str
              IF CHARINDEX(REVERSE(@split_str),REVERSE(@long_str_Tmp))>1    
                  SET @long_str_Tmp=@long_str_Tmp+@split_str    
              ELSE   
                  SET @long_str_Tmp=@long_str_Tmp    
              IF CHARINDEX(@split_str,@long_str_Tmp)=0
                  Insert INTO @tmp select @long_str_Tmp 
              ELSE
                  BEGIN
                      WHILE CHARINDEX(@split_str,@long_str_Tmp)>0    
                          BEGIN   
                              SET @short_str=SUBSTRING(@long_str_Tmp,1,CHARINDEX(@split_str,@long_str_Tmp)-1)    
                              DECLARE @long_str_Tmp_LEN INT,@split_str_Position_END int   
                              SET @long_str_Tmp_LEN = LEN(@long_str_Tmp)    
                              SET @split_str_Position_END = LEN(@short_str)+@split_str_length    
                              SET @long_str_Tmp=REVERSE(SUBSTRING(REVERSE(@long_str_Tmp),1,@long_str_Tmp_LEN-@split_str_Position_END))
                              IF @short_str<>'' Insert INTO @tmp select @short_str    
                          END           
                  END
              RETURN     
          END
          GO


          posted on 2013-11-08 16:57 Ke 閱讀(796) 評論(0)  編輯  收藏 所屬分類: sql server
          主站蜘蛛池模板: 乐业县| 革吉县| 景泰县| 高雄县| 澜沧| 威信县| 阿城市| 留坝县| 鄂托克旗| 涞水县| 建水县| 孟津县| 普安县| 清水河县| 新巴尔虎右旗| 新民市| 阜阳市| 永宁县| 全椒县| 富锦市| 彭泽县| 明溪县| 高唐县| 江西省| 淮阳县| 古田县| 和平区| 施秉县| 资溪县| 乐亭县| 汉川市| 建宁县| 河东区| 巴东县| 台南县| 桓台县| 云南省| 高台县| 金寨县| 泰来县| 保康县|