已知一个字符串 '88+spp/67yi'
通过函数把数字取出来:8867请问用什么函数?
通过函数把数字取出来:8867请问用什么函数?
解决方案 »
- 求教一查询语句
- 如何写?急
- 关于一个函数
- 这样的语句为何出错?
- SQL 语句 字符串取出的问题,想了好久没想出怎么办,请大家帮我看下,谢谢!
- 关于索引
- 数据库不知何故停了,准备重装,怎样备份数据库?着急?着急?着急?后天要用呀!
- 计算问题,有没有128的整形?(在线等待大侠的指教)
- ◇◆◇ 毕业设计:Elite Listen & Response 英语听力训练软件 (enmity) IX ◇◆◇
- 如何用存储过程实现从工作出发Access表中导入到sql2000中来
- select s# from sc a where c#='1001' and exists (select* from sc where a.s#=s
- 怎样在SQL2000中建立存储过程
insert into tb values('88+spp/67yi')
insert into tb values('88+spp/68yi')
go
create function getnewstr(@oldstr varchar(100)) returns varchar(100)
as
begin
declare @i int
set @i = 1
while @i <= len(@oldstr)
if substring(@oldstr, @i, 1) like('[^0-9]')
set @oldstr = replace(@oldstr, substring(@oldstr, @i, 1), '')
else
set @i = @i +1
return @oldstr
end
goselect col = dbo.getnewstr(col) from tb where col like('%[^0-9]%')drop table tb
drop function dbo.getnewstr/*
col
---------
8867
8868(所影响的行数为 2 行)
*/