Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server sqlserver中的模式匹配_Sql Server_Sql Server 2008_Sql Server 2005 - Fatal编程技术网

Sql server sqlserver中的模式匹配

Sql server sqlserver中的模式匹配,sql-server,sql-server-2008,sql-server-2005,Sql Server,Sql Server 2008,Sql Server 2005,结果是这样显示的 select Document_id from Document_Master where Document_id like 'APJ1.000753%' 但我想基于下划线计数,结果应该是 APJ1.000753_DIS001.PDF APJ1.000753_IP753_DIS001.PDF APJ1.000753_IP753_OTH001(1).PDF APJ1.000753_IP753_OTH001(2).PDF APJ1.000753_IP753_OTH00

结果是这样显示的

select Document_id 
from Document_Master 
where Document_id like 'APJ1.000753%'
但我想基于下划线计数,结果应该是

APJ1.000753_DIS001.PDF

APJ1.000753_IP753_DIS001.PDF

APJ1.000753_IP753_OTH001(1).PDF

APJ1.000753_IP753_OTH001(2).PDF

APJ1.000753_IP753_OTH001.PDF

APJ1.000753_OTH001.PDF
APJ1.000753_DIS001.PDF

APJ1.000753_OTH001.PDF

APJ1.000753_IP753_DIS001.PDF

APJ1.000753_IP753_OTH001(1).PDF

APJ1.000753_IP753_OTH001(2).PDF

APJ1.000753_IP753_OTH001.PDF
select Document_id
from Document_Master
where Document_id like 'APJ1.000753%'
order by len(Document_id) - len(replace(Document_id, '_', '')), Document_id