LutzM (10/4/2011)
Since [ is a meta-character in wildcard expressions, you'll need to wrap it with another set of brackets:
SELECT PATINDEX('%[[]%',mytextfield)
Interestingly, that same pattern doesn't work for the closing square bracket (I'm on 2012).
Works:
DECLARE @strPattern nvarchar(10)
SELECT @strPattern = '%[[]%'
SELECT '123]456', PATINDEX(@strPattern, '123[456')
Doesn't work:
DECLARE @strPattern nvarchar(10)
SELECT @strPattern = '%[]]%'
SELECT '123]456', PATINDEX(@strPattern, '123]456')