I have a table with many columns with 2.1M rows. Here are the columns which are related with my problem :
Column_name Type Computed Length Prec Scale Nullable TrimTrailingBlanks FixedLenNullInSource Collation
id int no 4 10 0 no (n/a) (n/a) NULL
val varchar no 15 yes no yes SQL_Latin1_General_CP1_CI_AS
I want to return rows which contain characters other than A-Z
, a-z
, 0-9
, (space) and
_
in column val
.
Sample Data :
INSERT INTO tabl
(id, val)
VALUES (1, 'Extemporè'),
(2, 'Aâkash'),
(3, 'Driver 12'),
(4, 'asd'),
(5, '10'),
(6, 'My_Car'),
(7, 'Johnson & Sons'),
(8, 'Johan''s Service'),
(9, 'Indus Truck')
Expected output :
id val
-- -----------
1 Extemporè
2 Aâkash
7 Johnson & Sons
8 Johan's Service
I found similar question here but it is also not giving expected results :
SELECT *
FROM tabl
WHERE val LIKE '%[^A-Z0-9 _]%'
Gives result :
id val
-- ----------
7 Johnson & Sons
8 Johan's Service