Alphabet 4 numeric 1 Alphabet), we can use the following query.
SELECT * FROM customers
WHERE Pancard LIKE '[A-Z][A-Z][A-Z][A-Z][A-Z][0-9][0-9][0-9][0-9][A-Z]'
To fetch all customer, whose postal code does not have any alphabet.
SELECT * FROM customers
WHERE PostalCode
NOT LIKE '%[A-Z]%'
To fetch all customer, whose postal code is alpha numeric
SELECT * FROM customers
WHERE PostalCode
LIKE '%[A-Z]%' AND PostalCode
LIKE '%[0-9]%'
To fetch all customer, whose first character of postal code is not vowels
SELECT * FROM customers
WHERE PostalCode
LIKE '[^aeiou]%'
To fetch all customer, whose has postal code does not contain special characters @ ,# ,$ and %
SELECT * FROM customers WHERE
PostalCode
NOT LIKE '%[@#$%]%'
To fetch all customers, whose postal code contain the character '%'. We have to use escape character as '%' used for wild card search.
SELECT * FROM customers WHERE
PostalCode
LIKE '%@%%' ESCAPE '@'
To fetch all customers, whose postal code starts with anything but second character is A to D
SELECT * FROM customers WHERE
PostalCode
LIKE '_[A-D]%'
These are the common pattern search option available in SQL server . We can mix and match this to make more complicated pattern search.
If you liked this post, do like my page on FaceBook