首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-01-22 
求助﹕怎样删除数据列中的中文字浮和特定的符号求助﹕怎样删除数据列中的中文字浮和特定的符号如﹕张三(alex.

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

如﹕

张三(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 )

热点排行