一张表 table1
id st
1 12345_8
2 23456_7
3 56789_0
4 34567_1
5 34656_2想得到
id st
1 123458
2 234567
3 567890
4 345671
5 346562
这样的结果,SQL语句该怎么写?
id st
1 12345_8
2 23456_7
3 56789_0
4 34567_1
5 34656_2想得到
id st
1 123458
2 234567
3 567890
4 345671
5 346562
这样的结果,SQL语句该怎么写?
--帮楼上的修改一下 :)select id,REPLACE(st,'_','') as st from table1
set @str='56789_0'
select replace(@str,'_','')----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
567890(1 行受影响)
(
id int identity(1,1) primary key,
st nvarchar(50)
)
insert into #TT select '12345_8'
insert into #TT select '23456_7'
insert into #TT select '56789_0'
insert into #TT select '34567_1'
insert into #TT select '34656_2'select id,replace(st,'_','') st from #TT
id st
----------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 123458
2 234567
3 567890
4 345671
5 346562(5 行受影响)