截取字符
请问一下表A:
ID comment
1 12*13
2 124*3
3 ASD*4R
4 23D
.....
规则,若有*,截取*前面的数值,若没有,只需带出原有的数值
[解决办法]
declare @T table (ID int,comment varchar(6))insert into @Tselect 1,'12*13' union allselect 2,'124*3' union allselect 3,'ASD*4R' union allselect 4,'23D'select left(comment+'*',charindex('*',comment+'*')-1) from @T/*12124ASD23D*/