ren
ren

Reputation: 3993

PatIndex match regex

I've been struggling to find a regex that using PatIndex would match anything and including to the first dot. For example dbo. in dbo.Table. Any help?

The best I had was select PatIndex('%_.%', 'dbo.Table') but that leaves the dot.

Upvotes: 0

Views: 1216

Answers (1)

Waqar Janjua
Waqar Janjua

Reputation: 6123

Upto my knoweldge, there is no need to use _ in the pattern, the PATINDEX always returns the index of first matching word or character.

Try this:

select PatIndex('%.%', 'dbo.Table')
-- output: 4
select PatIndex('%.%', 'servername.dbo.Table')
-- output: 11

Upvotes: 1

Related Questions