Solved

IF Statement then remove first 4 characters

Posted on 2013-11-07
2
192 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

733 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