的一種方式是數字。如果文件名中只有一個.
字符,此解決方案才能正常工作。
select * from web_pub_subfile
where isnumeric(left(file_name,charindex('.',file_name)-1)) = 1
注:
ISNUMERIC返回1,對於一些字符不是數字,如加號(+),減號( - ),和有效的貨幣符號,如美元符號( $)。
處理與複式.
字符的文件名,如果總是有一個.filetype
擴展,使用
select * from web_pub_subfile
where isnumeric(left(file_name,len(file_name)-charindex('.',reverse(file_name)))) = 1
and charindex('.',file_name) > 0
Sample demo
正如@Blorgbeard提出的意見,以避免使用isnumeric
,使用
select * from web_pub_subfile
where left(file_name,len(file_name)-charindex('.',reverse(file_name))) NOT LIKE '%[^0-9]%'
and len(left(file_name,len(file_name)-charindex('.',reverse(file_name)))) > 0
LIKE語法不是正則表達式:https: //msdn.microsoft.com/en-us/library/ms179859.aspx – Blorgbeard