隨筆 - 6  文章 - 129  trackbacks - 0
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(14)

          隨筆檔案(6)

          文章分類(467)

          文章檔案(423)

          相冊

          收藏夾(18)

          JAVA

          搜索

          •  

          積分與排名

          • 積分 - 826758
          • 排名 - 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
          主站蜘蛛池模板: 河北区| 遵义市| 元朗区| 专栏| 馆陶县| 定日县| 北票市| 富宁县| 治县。| 石柱| 隆回县| 乌苏市| 滁州市| 益阳市| 乡城县| 潼南县| 南溪县| 蓝山县| 舒城县| 宝山区| 介休市| 改则县| 奉节县| 鄂尔多斯市| 胶州市| 蛟河市| 余庆县| 灵宝市| 广灵县| 安西县| 汝州市| 丹东市| 东丽区| 新建县| 高尔夫| 黄石市| 达州市| 绥德县| 昌吉市| 焦作市| 桓台县|