IS it possible to use the 'Where' clause in SQL to only show a field containing only letters & Numbers?

前端 未结 5 723
攒了一身酷
攒了一身酷 2021-01-14 07:56

I want to be able to select only the field where a certain field contains both letters and numbers. for example:

Select [field1], [field2] 

from [db1].[tabl         


        
5条回答
  •  抹茶落季
    2021-01-14 08:12

    I believe PATINDEX will do the trick for you. The query below checks for non 0-9 and non a-z characters, returning 0 if it doesn't find any (i.e., only #s and letters)

    Select [field1], [field2] 
    from [db1].[table1] 
    where patindex('%[^0-9a-z]%', [field2]) = 0
    

提交回复
热议问题