Wildcard of Number in SQL Server

前端 未结 2 654
醉梦人生
醉梦人生 2021-02-13 06:08

How to match numbers in SQL Server \'LIKE\'.

SpaceName
------------ 
| New_Space_1
| .
| .
| New_Space_8 
| New_Space_9
| New_Space_10
| New_Space_11
| New_Space         


        
相关标签:
2条回答
  • 2021-02-13 06:30

    This solution from @SteveKass works perfect.

    SELECT SpaceName FROM SpaceTable WHERE SpaceName LIKE 'New[_]Space[_]%' AND SpaceName NOT LIKE 'New[_]Space[_]%[^0-9]%' 
    
    0 讨论(0)
  • 2021-02-13 06:32

    what about

    SELECT SpaceName FROM SpaceTable
        WHERE SpaceName LIKE 'New[_]Space[_][0-9]%' 
    

    The reason I put underscore in brackets is because in a regular expression _ means Any single character. Read up on like here http://msdn.microsoft.com/en-us/library/ms179859.aspx

    0 讨论(0)
提交回复
热议问题