读书人

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

发布时间: 2012-09-21 15:47:26 作者: rapoo

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

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 行受影响)**/ 

读书人网 >SQL Server

热点推荐