Get rows that contain only certain characters
问题 I want to get only those rows that contain ONLY certain characters in a column. Let's say the column name is DATA. I want to get all rows where in DATA are ONLY (must have all three conditions!): Numeric characters ( 1 2 3 4 5 6 7 8 9 0 ) Dash ( - ) Comma ( , ) For instance: Value "10,20,20-30,30" IS OK Value "10,20A,20-30,30Z" IS NOT OK Value "30" IS NOT OK Value "AAAA" IS NOT OK Value "30-" IS NOT OK Value "30," IS NOT OK Value "-," IS NOT OK 回答1: Try patindex: select * from( select '10,20