Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
HiIn one of the columns of my table it shows the path of Reports like following./Product/Customer/Aging/Information/Asset/Dest/Term/Auto/Red/Fees/Detail/BlueBut i want only first word from L-R within Slashes. i want my result set to be look like------------------ProductInformationTermFeesAny Idea?ThanksDeeps
tkizer
Almighty SQL Goddess
38200 Posts
Posted - 2008-08-04 : 19:57:41
DECLARE @s varchar(50)SET @s = '/Product/Customer/Aging'SELECT SUBSTRING(@s, 2, CHARINDEX('/', SUBSTRING(@s, 2, DATALENGTH(@s))) - 1)Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2008-08-05 : 04:55:16
or try this if data dont have more than 4 slashes
select parsename(col,3) from( select replace(col,'/','.') as col from table) as t