Question: I want to be able to differentiate between a string that is alphnumeric and a string that is in hex format. 

My current query is:

```
<columnName> LIKE '?_____=' + REPLICATE('[0-9A-Fa-f]',16)

```

I found this method of searching for hex ID's online and I thought it was working. However after getting a significantly larger sample size I can see a high false positive rate in my results. The problem is that this gives me all the results I do want but it also gives me a bunch of results I dont care about. For example:

I want to see:

```
<url>.php?mains=d7ad916d1c0396ff

```

but i dont want to see:

```
<url>.php?mblID=2007012422060265

```

The difference between the 2 strings is that the 16 characters at the end that i want to collect are all numeric and not a hex ID. What are some ways you guys use to limit the results to hex ID only? Thanks in advnace.

**UPDATE:**
Juergen brought up a good point, the second number could be a hex value to. Not all hex numbers contain [a-F]. I would like to rephrase the question to state that I am looking for an ID with both letters and numbers in it, not just numbers.

Answer: 
The simplest way is just to add a separate clause for that restriction:

```
    <columnName> LIKE '?_____=' + REPLICATE('[0-9A-Fa-f]',16)
AND <columnName> NOT LIKE '?_____=' + REPLICATE('[0-9]',16)

```
It should be fairly simple to determine if a string contains only numbers...

Setting up a test table:

```
CREATE TABLE #Temp (Data char(32)  not null)

INSERT #Temp
  values ('<url>.php?mains=d7ad916d1c0396ff')
        ,('<url>.php?mblID=2007012422060265 ')

```

Write a query:

```
SELECT
   right(Data, 16)             StringToCheck
  ,isnumeric(right(Data, 16))  IsNumeric
 from #Temp

```

Get results:

```
StringToCheck   IsNumeric
d7ad916d1c0396ff    0
2007012422060265    1

```

So, if the IsNumeric function returns 0, it could be a hex string.

This makes several assumptions:

* The rightmost 16 characters are what you want to check
* You only ever hit 16 characters. I don't know when the string would get too long to check.
* A non-numeric character means hex. Any chance of "Q" or "~" being embedded in the string?