StuartBombay
Programmer
I know I may catch some flack for parsing strings in a SP, but it must be done.
I'm having an issue with SUBSTRING, in the following code, if I up the '23' to '24' I get no results. If I up it to '25' I get the error
"Invalid length parameter passed to the SUBSTRING function"
I've done some research and found the SUBSTRING seems to have limitations in SQL2005. OK, I still need parse this string, but I'm at a loss.
The real code, by the way, didn't use the number 25,
(LEN(@OU)+8 was there. I'm trying to find the top most OU, unless that OU is IN('staff', 'itinerant'), in that case I need the next OU down.
Has anyone found a solution for this? It took me half a day to get this far... now I'm crushed to find it has this limitation!
I'm having an issue with SUBSTRING, in the following code, if I up the '23' to '24' I get no results. If I up it to '25' I get the error
"Invalid length parameter passed to the SUBSTRING function"
Code:
DECLARE @TheOU varchar(5000),
@OU varchar(5000)
SET @OU = 'uid=sabinguy,OU=staff,ou=sabin,OU=ES,o=company'
select
SUBSTRING(@OU,
CHARINDEX(',',@OU)+ 23,
(CHARINDEX(',',@OU,CHARINDEX(',',@OU)+23)) - (CHARINDEX(',',@OU)+23))
I've done some research and found the SUBSTRING seems to have limitations in SQL2005. OK, I still need parse this string, but I'm at a loss.
The real code, by the way, didn't use the number 25,
(LEN(@OU)+8 was there. I'm trying to find the top most OU, unless that OU is IN('staff', 'itinerant'), in that case I need the next OU down.
Has anyone found a solution for this? It took me half a day to get this far... now I'm crushed to find it has this limitation!