日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

如何在SQL Server數(shù)據(jù)庫中拆分字符串函數(shù)_Mssql數(shù)據(jù)庫教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:淺談在SQL Server2005中進(jìn)行錯(cuò)誤捕捉
任何程序都可能出現(xiàn)錯(cuò)誤,在SQL Server中執(zhí)行Transact-SQL也不例外。如果在Transact-SQL中發(fā)生了錯(cuò)誤,一般有兩種捕捉錯(cuò)誤的方法,一種是在客戶端代碼(如C#、Delphi等)中使用類似try

如何在SQL Server數(shù)據(jù)庫中拆分字符串函數(shù)呢?

具體方法如下:

以下為引用的內(nèi)容:
  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é)果:

以下為引用的內(nèi)容:
  str_id   string
  1       1
  2       1
  3       2
  4      50

分享:解析SQL Server 2000 SP4與數(shù)據(jù)鏈接池問題
今天遠(yuǎn)程連接一臺(tái)xp sp2上的SQL,報(bào)錯(cuò)信息如下: 以下為引用的內(nèi)容:   Timeout expired. The timeout period elapsed prior to obtaining

來源:模板無憂//所屬分類:Mssql數(shù)據(jù)庫教程/更新時(shí)間:2009-08-30
相關(guān)Mssql數(shù)據(jù)庫教程