Hi,
I need to scan some character data for the presence of certain "invalid"
characters. The characters I need to scan for are
!@.#$%^&*()_+={}[]|\:;"<>,/?
The PATINDEX function works so long as the ] character is omitted, e.g.
set @.s = 'foo$'
select patindex('%[!@.#$%^&*()_+={}[|\:;"<>,/?]%', @.s)
-- returns 4
Is there any way to tell PATINDEX or LIKE to treat ] as a literal character
within a character set?
Thanks,
DanielDECLARE @.s VARCHAR(20)
SET @.s = 'foo]bar['
SELECT PATINDEX( '%]%', @.s ), PATINDEX( '%[[]%', @.s )
Anith|||Surround the OPENING bracket with brackets.
set @.s = 'foo$'
select patindex('%[!@.#$%^&*()_+={}[[]|\:;"<>,/?]%', @.s)
-- returns 0
"Daniel Pratt" <kolREMOVETHISkata_is@.hotmail.com> wrote in message
news:usIkVir6FHA.1420@.TK2MSFTNGP09.phx.gbl...
> Hi,
> I need to scan some character data for the presence of certain "invalid"
> characters. The characters I need to scan for are
> !@.#$%^&*()_+={}[]|\:;"<>,/?
> The PATINDEX function works so long as the ] character is omitted, e.g.
> set @.s = 'foo$'
> select patindex('%[!@.#$%^&*()_+={}[|\:;"<>,/?]%', @.s)
> -- returns 4
> Is there any way to tell PATINDEX or LIKE to treat ] as a literal
> character within a character set?
> Thanks,
> Daniel
>
No comments:
Post a Comment