比如我通过查询READ_COUNT_LOG字段得到:20081001:0;20081101:0;20081201:0;20090101:0;20090201:0;20090301:620090401:7;20090501:8;20090601:4;20090701:420091001:13;20091101:26;20091201:9;20100101:12等等这些类似的字符串,我现在就是希望这个在得到的READ_COUNT_LOG中得到最后一个冒号后面的所有字符
调试欢乐多
string inputData = "20081001:0;20081101:0;20081201:0;20090101:0;20090201:0;20090301:6";//输入内容
int lastColonIndex = inputData.LastIndexOf(":");//获取最后一个冒号的索引
string resultData = inputData.Substring(lastColonIndex + 1);//得到最后一个冒号后面的所有字符
declare @source nvarchar(1000)
set @source = '20091001:13;20091101:26;20091201:9;20100101:12'
print reverse (LEFT(Reverse(@source), charindex(':', Reverse(@source)) -1 ))
把reverse (LEFT(Reverse(@source), charindex(':', Reverse(@source)) -1 )) 用到你的select语句里即可。