Page 1 of 1

Substring examples

Posted: Fri Aug 21, 2020 3:09 pm
by hudatolah

Code: Select all

substring(
SUBSTRING(
       substring('/'+cast(cs.attributedatasourcelist as nvarchar(1024)),1,patindex(@fieldid,'/'+cast(cs.attributedatasourcelist as nvarchar(1024)))+len(@fieldid)-3), 
       LEN(substring('/'+cast(cs.attributedatasourcelist as nvarchar(1024)),1,patindex(@fieldid,'/'+cast(cs.attributedatasourcelist as nvarchar(1024)))+len(@fieldid)-3)) -  
       CHARINDEX('/',REVERSE(substring('/'+cast(cs.attributedatasourcelist as nvarchar(1024)),1,patindex(@fieldid,'/'+cast(cs.attributedatasourcelist as nvarchar(1024)))+len(@fieldid)-3))) + 2, 
       LEN(substring('/'+cast(cs.attributedatasourcelist as nvarchar(1024)),1,patindex(@fieldid,'/'+cast(cs.attributedatasourcelist as nvarchar(1024)))+len(@fieldid)-3))
       ),1,CHARINDEX(':',
       SUBSTRING(
       substring('/'+cast(cs.attributedatasourcelist as nvarchar(1024)),1,patindex(@fieldid,'/'+cast(cs.attributedatasourcelist as nvarchar(1024)))+len(@fieldid)-3), 
       LEN(substring('/'+cast(cs.attributedatasourcelist as nvarchar(1024)),1,patindex(@fieldid,'/'+cast(cs.attributedatasourcelist as nvarchar(1024)))+len(@fieldid)-3)) -  
       CHARINDEX('/',REVERSE(substring('/'+cast(cs.attributedatasourcelist as nvarchar(1024)),1,patindex(@fieldid,'/'+cast(cs.attributedatasourcelist as nvarchar(1024)))+len(@fieldid)-3))) + 2, 
       LEN(substring('/'+cast(cs.attributedatasourcelist as nvarchar(1024)),1,patindex(@fieldid,'/'+cast(cs.attributedatasourcelist as nvarchar(1024)))+len(@fieldid)-3))
       ))),



substring(pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON,charindex(',',pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON)+2,len(pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON)-charindex(',',pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON)+2) +'.'+ substring(pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON,1,charindex(',',pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON)-1) 


lower(substring(pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON,charindex(',',pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON)+2,len(pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON)
-charindex(',',pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON)+2) +'.'+ substring(pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON,1,charindex(',',pl.TECHNOLOGY_ORG_RESPONSIBLE_PERSON)-1))
AS [APP_PLATFORM_TechSVP_Name]