A,B,C
1,2,12354/
3,4,54156%
5,6,87415426$
7,8,15646
...........
我要把C列后面的那些字符去掉(C列有的时候又没有那些字符的),不知道在做,请各位老大帮帮忙
5 个解决方案
#1
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
#2
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太烂!很烂
#3
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
这是我修改的,怎么样啊?这样也可以的?老大,我还能不能再问你一个问题啊?一会给你分
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
这是我修改的,怎么样啊?这样也可以的?老大,我还能不能再问你一个问题啊?一会给你分
#4
上面就行了
select ascii(' ')as 全角,ascii(' ')as 半角
全角 半角
161 32
select ascii(' ')as 全角,ascii(' ')as 半角
全角 半角
161 32
#5
mark
#1
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
#2
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太烂!很烂
#3
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
这是我修改的,怎么样啊?这样也可以的?老大,我还能不能再问你一个问题啊?一会给你分
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
这是我修改的,怎么样啊?这样也可以的?老大,我还能不能再问你一个问题啊?一会给你分
#4
上面就行了
select ascii(' ')as 全角,ascii(' ')as 半角
全角 半角
161 32
select ascii(' ')as 全角,ascii(' ')as 半角
全角 半角
161 32
#5
mark