declare @a varchar(20) set @a='18000元' select left(@a,patindex('%[ 吖-座]%',@a)-1)
select a=left(colname,patindex('%[吖-座]%',colname)-1) from tb --colname为字段名
考虑到有写字段没有汉字 select a=case when patindex('%[吖-座]%',colname)<>0 then left(colname,patindex('%[吖-座]%',colname)-1) else colname end from tb
已经测试通过:CREATE TABLE TB_TEST(Name varchar(10)) insert into TB_TEST(name) select('20万') insert into tb_test(name) select('1000元')UPDATE TB_TEST SET NAME=REPLACE(NAME,'万','')UPDATE TB_TEST SET NAME=REPLACE(NAME,'元','')select * from TB_TEST drop table TB_TEST
set @a='18000元'
select left(@a,patindex('%[ 吖-座]%',@a)-1)
select a=case when patindex('%[吖-座]%',colname)<>0
then left(colname,patindex('%[吖-座]%',colname)-1)
else colname end
from tb
insert into TB_TEST(name) select('20万')
insert into tb_test(name) select('1000元')UPDATE TB_TEST SET NAME=REPLACE(NAME,'万','')UPDATE TB_TEST SET NAME=REPLACE(NAME,'元','')select * from TB_TEST
drop table TB_TEST