Substring examples

I decided to add this forum to keep track of solutions for DB related problems.
I have worked with some brilliant people in my life and the solutions to issues that are usually beyond something you can get at Jack in Box Jackson. They deserve historical marker. This is the historical marked on my map.
Pouzivej data base
Post Reply
hudatolah
Site Admin
Posts: 152
Joined: Thu Apr 04, 2013 8:10 pm
Are You a Headhunter?: Affirmative
Surfer?: Yes

Substring examples

Post by hudatolah » Fri Aug 21, 2020 3:09 pm

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]
The Blackholesurfer. My surfboard has teeth.