... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2005-07-27

MS SQL Server Bug

The PATINDEX function doesn't seem to handle brackets properly.  The statement:

select patindex('%[%', 'abc[]def')

returns '0' instead of '4'.

After some experimentation, I see that brackets are being interpreted according to the usual regexp syntax.  PATINDEX is not documented to support regular expressions, so this is unexpected.  As per regexps, the following statement works:

select patindex('%[[]%', 'abc[]def')

Blog Archive