Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing Text Field

Status
Not open for further replies.

LAM986

Programmer
Nov 4, 2009
15
US
Hello,
I am querying the Catalog table in the ReportServer for column [Path] which houses the location of a report. I want to parse that to return only the main folder. So the data reads /CSS/Management. I only want CSS. Can anyone direct me how to do that. This is what I have so far, any help would be much appreciated. Thank you.

SELECT LTrim(RTrim([Path])
, charindex(' ', [Path])
, LTrim(RTrim(substring([path], 1, charindex(' ', [path]))))
FROM [Catalog]

 
If you ALWAYS have the path stored like this:
/main/sub.....
try this:
Code:
declare @TestPath as varchar(8000)
SET @TestPath = '/CSS/Management'

SELECT CASE WHEN CHARINDEX('/',@TestPath,2) = 0
                 THEN @TestPath
            ELSE LEFT(@TestPath,CHARINDEX('/',@TestPath,2)-1) END

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top