2 回答

慕尼黑5688855
TA貢獻1848條經驗 獲得超2個贊
sqlserver中和java中indexof類似的函數是字符串函數中的charindex。
CHARINDEX函數返回字符或者字符串在另一個字符串中的起始位置。
CHARINDEX函數調用方法如下:
CHARINDEX ( expression1 , expression2 [ , start_location ] )
------------------
一個修改字符串的sql語句用到了charindex,substring等函數的綜合使用
update [UpdateString]
set b=
substring(b,0,charindex(',',b,0))+','+
cast(cast(substring(substring(b,charindex(',',b,0)+1,len(b)),
0,charindex(',',substring(b,charindex(',',b,0)+1,len(b)),0)) as int)+2 as varchar)+','+
substring(substring(b,charindex(',',b,0)+1,len(b)),
charindex(',',substring(b,charindex(',',b,0)+1,len(b)),0)+1,
len(substring(b,charindex(',',b,0)+1,len(b))))
- 2 回答
- 0 關注
- 881 瀏覽
添加回答
舉報
0/150
提交
取消