日期:2014-05-18  浏览次数:20467 次

求助﹕怎样删除数据列中的中文字浮和特定的符号
求助﹕怎样删除数据列中的中文字浮和特定的符号

如﹕

张三(alex.zang@sohu.com)
李四(scott.li@sohu.com)

我想得到﹕

alex.wang@sohu.com
scott.li@sohu.com


------解决方案--------------------

create table #tt(aa varchar(50))
insert #tt
select '张三(alex.zang@sohu.com) ' union all
select '李四(scott.li@sohu.com) '

select replace(stuff(aa,1,charindex( '( ',aa), ' '), ') ', ' ' ) from #tt

--------
alex.zang@sohu.com
scott.li@sohu.com

------解决方案--------------------

declare @str varchar(100)
set @str= '张三(alex.zang@sohu.com) '
print CHARINDEX ( '( ' , @str)
print substring(@str,CHARINDEX ( '( ' , @str)+1,len(@str)-CHARINDEX ( '( ' , @str)-1 )

------解决方案--------------------
update:


create table #tt(aa varchar(50))
insert #tt
select '张三(alex.zang@sohu.com) ' union all
select '李四(scott.li@sohu.com) '

update #tt set aa=replace(stuff(aa,1,charindex( '( ',aa), ' '), ') ', ' ' )
------解决方案--------------------
update 表名
set 列名 = substring(列名,CHARINDEX ( '( ' , 列名)+1,len(列名)-CHARINDEX ( '( ' , 列名)-1 )