表中某列中的数据如下:
111.abc
222.abc
333.abc
444.abc
想用语句直接去掉“.abc” 成如下结果:
111
222
333
444
请教这个语句如何写,谢谢!
------解决方案--------------------
- SQL code
if object_id('[tb]') is not null drop table [tb]gocreate table [tb]([col] varchar(7))insert [tb]select '111.abc' union allselect '222.abc' union allselect '333.abc' union allselect '444.abc'goupdate tb set col=replace(col,'.abc','') where charindex('.abc',col)>0goselect * from tb/**col-------111222333444(4 行受影响)**/