日期:2014-05-17  浏览次数:20638 次

一个很基础的问题,如何批量改内容
表中某列中的数据如下:

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]
go
create table [tb]([col] varchar(7))
insert [tb]
select '111.abc' union all
select '222.abc' union all
select '333.abc' union all
select '444.abc'
go

update tb set col=replace(col,'.abc','') where charindex('.abc',col)>0
go

select * from tb

/**
col
-------
111
222
333
444

(4 行受影响)
**/