试试这个: --drop table acreate table a(b nvarchar(100))insert into a select '0244ml招财招福(餐具组合)' union all select '0247ml台灯' union all select '0258#顺适宝钻石1号尖匙' union all select '0260#顺适宝钻石1号叉' union all select '0262#顺适宝钻花2号尖匙' go select left(b,patindex('%[吖-座]%',b)-1) as '提取出的数字' from a /* 提取出的数字 0244ml 0247ml 0258# 0260# 0262# */
--drop table acreate table a(b nvarchar(100))insert into a
select '0244ml招财招福(餐具组合)' union all
select '0247ml台灯' union all
select '0258#顺适宝钻石1号尖匙' union all
select '0260#顺适宝钻石1号叉' union all
select '0262#顺适宝钻花2号尖匙'
go
select
left(b,patindex('%[吖-座]%',b)-1) as '提取出的数字'
from a
/*
提取出的数字
0244ml
0247ml
0258#
0260#
0262#
*/
服务器: 消息 536,级别 16,状态 3,行 1
向 substring 函数传递了无效的 length 参数。
select *
from a
WHERE LEFT(b,1) NOT BETWEEN '0' AND '1'这个查一下?
from a