Last active
March 1, 2022 19:04
-
-
Save BenjaminAdams/df9e8585f1fd55130674 to your computer and use it in GitHub Desktop.
Search a SQL server field for a creditcard number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET ROWCOUNT 10000 | |
SELECT SomeField | |
FROM tablename | |
WHERE patindex('%[3|4|5|6][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%',SomeField) > 0 | |
or to get the unique numbers | |
SET ROWCOUNT 50 | |
SELECT distinct SUBSTRING (SomeField ,patindex('%[3|4|5|6][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%',SomeField) , 12 ) | |
FROM tablename | |
WHERE patindex('%[3|4|5|6][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%',SomeField) > 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment