日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
在SQLServer數(shù)據(jù)庫(kù)中拆分字符串函數(shù)

SQL Server數(shù)據(jù)庫(kù)中拆分字符串函數(shù)的具體方法:

創(chuàng)新互聯(lián)建站自2013年創(chuàng)立以來,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目做網(wǎng)站、成都網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元平定做網(wǎng)站,已為上家服務(wù),為平定各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18980820575

  CREATE FUNCTION uf_StrSplit '1.1.2.50','.'
  (@origStr varchar(7000), --待拆分的字符串
  @markStr varchar(100)) --拆分標(biāo)記,如','
  RETURNS @splittable table
  (
   str_id varchar(4000) NOT NULL, --編號(hào)ID
   string varchar(2000) NOT NULL --拆分后的字符串
  )
  AS
  BEGIN
  declare @strlen int,@postion int,@start int,@sublen int,
  @TEMPstr varchar(200),@TEMPid int
  SELECT @strlen=LEN(@origStr),@start=1,@sublen=0,@postion=1,
  @TEMPstr='',@TEMPid=0
  if(RIGHT(@origStr,1)<>@markStr )
  begin
  set @origStr = @origStr + @markStr
  end
  WHILE((@postion<=@strlen) and (@postion !=0))
  BEGIN
  IF(CHARINDEX(@markStr,@origStr,@postion)!=0)
  BEGIN
  SET @sublen=CHARINDEX(@markStr,@origStr,@postion)-@postion;
  END
  ELSE
  BEGIN
  SET @sublen=@strlen-@postion+1;
  END
  IF(@postion<=@strlen)
  BEGIN
  SET @TEMPid=@TEMPid+1;
  SET @TEMPstr=SUBSTRING(@origStr,@postion,@sublen);
  INSERT INTO @splittable(str_id,string)
  values(@TEMPid,@TEMPstr)
  IF(CHARINDEX(@markStr,@origStr,@postion)!=0)
  BEGIN
  SET @postion=CHARINDEX(@markStr,@origStr,@postion)+1
  END
  ELSE
  BEGIN
  SET @postion=@postion+1
  END
  END
  END
  RETURN
  END

  例如:select * from uf_StrSplit('1,1,2,50',',')

  輸出結(jié)果:

  str_id string
  1 1
  2 1
  3 2
  4 50

上文中涉及到很多的字符,對(duì)于一些初學(xué)者來說,可能是比較難理解,但是這個(gè)知識(shí)點(diǎn)確實(shí)是經(jīng)常會(huì)用到的,而且相當(dāng)實(shí)用,希望大家好好學(xué)習(xí),爭(zhēng)取能熟練的掌握。


新聞標(biāo)題:在SQLServer數(shù)據(jù)庫(kù)中拆分字符串函數(shù)
網(wǎng)頁(yè)鏈接:http://m.5511xx.com/article/cdjgcsi.html