Reputation: 37
Need special pattern for finding values that are 13 length chars, first of 12 are numbers for example 119910023525P
There are 2 Pattern :
LIKE '____________P'
or
LIKE '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]P'
Need something as '[0-9]{12}P'
It's Possible In MS-SQL Server ?
Upvotes: 1
Views: 77
Reputation: 1271111
You could use this logic:
(x like '%P' and x not like '%[^0-9]%P' and len(x) = 13)
But that is about the same amount of typing as just manually replicated [0-9]
12 times.
Upvotes: 0
Reputation: 453910
There are no quantifiers in the TSQL pattern syntax.
You can use
LIKE REPLICATE('[0-9]',12) + 'P'
Upvotes: 2
Reputation: 112
Maybe the REGEXP() function will help you with this task.
Upvotes: -1