22,298
社区成员
发帖
与我相关
我的任务
分享----------------------------------------------------------------
-- Author :fredrickhu(小F,向高手学习)
-- Date :2009-12-06 21:08:23
-- Version:
-- Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86)
-- Nov 24 2008 13:01:59
-- Copyright (c) 1988-2005 Microsoft Corporation
-- Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 3)
--
----------------------------------------------------------------
--> 测试数据:[tb]
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([ID] int,[TelNo] bigint,[Area] varchar(12),[Region] varchar(14))
insert [tb]
select 1,13888000001,'河北省唐山市','河北省动感地带' union all
select 2,13888000002,'河北省保定市','河北省神州行' union all
select 3,13500000012,'广东省中山市','广东省动感地带' union all
select 4,15014200023,'广东省珠海市','广东省全球通'
--------------开始查询--------------------------
update
tb
set
area=REPLACE(Area,'省','') ,Region=REPLACE(Region,'省','')
select * from tb
----------------结果----------------------------
/* ID TelNo Area Region
----------- -------------------- ------------ --------------
1 13888000001 河北唐山市 河北动感地带
2 13888000002 河北保定市 河北神州行
3 13500000012 广东中山市 广东动感地带
4 15014200023 广东珠海市 广东全球通
(4 行受影响)
*/
UPDATE TB SET Area=REPLACE(Area,'省',''),Region=REPLACE(Region,'省','')update xxxx
set Area=REPLACE(Area,'省',''),Region=REPLACE(Region,'省','')