Solved

IF Statement then remove first 4 characters

Posted on 2013-11-07
2
193 Views
Last Modified: 2013-11-08
I have a description field that has  the following:

<!A>Description of Product
<!B>Description of Next Product
DSC-Free Shipping
<!C>Description of Third Product

I'm wanting to put in a formula where if the description field contains "<" then I want to trim the first 4 characters. If there is no "<" at the beginning then do nothing. So in essence I want to just remove the "<!A>","<!B>","<!C>"
0
Comment
Question by:Southern_Gentleman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Assisted Solution

by:Steve Wales
Steve Wales earned 200 total points
ID: 39632694
Something like this:

select case 
         when substring(COL1,1,1) = '<' then substring(col1,5,len(col1)-4)
         else col1
       end
from
(select '<!A>Line 1' as COL1
union 
select 'Line 2'
union
select '<!B>Line 3') as a

Open in new window


Returns this:

Line 1
Line 2
Line 3
0
 
LVL 32

Accepted Solution

by:
awking00 earned 300 total points
ID: 39633277
select case when charindex('<',description) = 1 then right(description, len(description) - 4) else description end as description
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question