Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

IF Statement then remove first 4 characters

Posted on 2013-11-07
2
Medium Priority
?
196 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 23

Assisted Solution

by:Steve Wales
Steve Wales earned 800 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 1200 total points
ID: 39633277
select case when charindex('<',description) = 1 then right(description, len(description) - 4) else description end as description
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

609 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