Tips

  • 関数定義
 CREATE function Get_StrArrayStrOfIndex
 (
   @str varchar(1024),  --分割する対象の文字列
   @split varchar(10),  --分割するの文字列
   @index int --取得する分割した文字列のインデックス
 )
 returns varchar(1024)
 as
 begin
   declare @location int
   declare @start int
   declare @next int
   declare @seed int
 
   set @str=ltrim(rtrim(@str))
   set @start=1
   set @next=1
   set @seed=len(@split)
    
   set @location=charindex(@split,@str)
   while @location<>0 and @index>@next
   begin
     set @start=@location+@seed
     set @location=charindex(@split,@str,@start)
     set @next=@next+1
   end
   if @location =0 select @location =len(@str)+1
  
   return substring(@str,@start,@location-@start)
 end
  • 呼び出し
select dbo.Get_StrArrayStrOfIndex('8,9,4',',',2)


★月額105円~/容量最大30GB/機能満載! ロリポップ!レンタルサーバー ★

(画像の文字列を入力して下さい)

トップ   編集 凍結 差分 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2019/12/02 (月) 12:41:46 (1627d)

e[NȂECir Yahoo yV LINEf[^[Ōz500~`I
z[y[W ̃NWbgJ[h COiq@COsیI COze