在SQL数据库中怎么去掉某一列的中的一写特殊字符?

it_sql 2008-02-16 08:41:01
我有一些数据如下:
A,B,C
1,2,12354/
3,4,54156%
5,6,87415426$
7,8,15646
...........
我要把C列后面的那些字符去掉(C列有的时候又没有那些字符的),不知道在做,请各位老大帮帮忙
...全文
425 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wzy_love_sly 2008-02-16
  • 打赏
  • 举报
回复
上面就行了
select ascii(' ')as 全角,ascii(' ')as 半角

全角 半角
161 32
it_sql 2008-02-16
  • 打赏
  • 举报
回复
create table tb (a int,b int,c varchar(50))
insert into tb select 1,2,'12354/'
insert into tb select 3,4,'54156%'
insert into tb select 5,6,'87415426$'
insert into tb select 7,8,'15646'
insert into tb select 7,8,'156463 '
select a,b,RTRIM(c) as c into #s from tb
select a,b,
case when unicode(right(c,1)) not between 48 and 57
then left(c,len(c)-1)
else c end as c
from #s
drop table tb,#s
这是我修改的,怎么样啊?这样也可以的?老大,我还能不能再问你一个问题啊?一会给你分
wzy_love_sly 2008-02-16
  • 打赏
  • 举报
回复
create table #([unicode] varchar(10),[ascii] varchar(10))
declare @i int
set @i=1
while(@i<=128)
begin
insert into #
select char(@i),@i
set @i=@i+1
end

select * from #

看不到,csdn太烂!很烂
wzy_love_sly 2008-02-16
  • 打赏
  • 举报
回复
declare @tb table (a int,b int,c varchar(50))
insert into @tb select 1,2,'12354/'
insert into @tb select 3,4,'54156%'
insert into @tb select 5,6,'87415426$'
insert into @tb select 7,8,'15646'

select a,b,
case when unicode(right(c,1)) not between 49 and 58 or unicode(right(c,1)) not between 66 and 91 or unicode(right(c,1)) not between 98 and 123
then left(c,len(c)-2)
else c end as c
from @tb


a b c
1 2 1235
3 4 5415
5 6 8741542
7 8 156
JiangHongTao 2008-02-16
  • 打赏
  • 举报
回复
mark

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧