For some reason I can't get PATINDEX to find instances of the opening
bracket "[" although it finds the closing bracket "]" without any trouble.
Running the following script results in "0" for brakbegin and the correct
number for brakend.
UPDATE FOIdata
Set
brakbegin = PatIndex('%[%',Title_txt),
brakend = PatIndex('%]%',Title_txt)
Table Structure:
Title_txt text = "Oncovin (Lilly Research) [Leukemia] 12/04/1984 Medical
Officers Review"
brakbegin int
brakend int
Any idea what I'm doing wrong?
Terrytry this
declare @.Var varchar(50)
select @.var ='abc[def]zzz'
select PatIndex('%[[]%',@.var)
http://sqlservercode.blogspot.com/|||I don't know why this is happening but you could use CHARINDEX instead.
Declare @.text varchar(50)
Set @.Text = 'Oncovin (Lilly Research) [Leukemia] 12/04/1984 Medical
Officers Review'
Select charindex('[', @.Text)
Select Charindex(']', @.text, (charindex('[', @.Text)))
HTH
Barry|||Escape it:
PatIndex('%[]]%',Title_txt)
ML
http://milambda.blogspot.com/|||Thanks for all your excellent, quick help!
I didn't know about escaping the open bracket. That did the trick!
Thanks again!
Terry
Showing posts with label openingbracket. Show all posts
Showing posts with label openingbracket. Show all posts
Subscribe to:
Posts (Atom)