当前位置: 代码迷 >> Sql Server >> 一个很基础的有关问题,怎么批量改内容
  详细解决方案

一个很基础的有关问题,怎么批量改内容

热度:18   发布时间:2016-04-27 11:06:22.0
一个很基础的问题,如何批量改内容
表中某列中的数据如下:

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 行受影响)**/
  相关解决方案