SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Simple IF syntax help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

lcsgeek
Starting Member

USA
38 Posts

Posted - 06/29/2012 :  08:59:55  Show Profile  Reply with Quote
@endPercentile is a string that occasionally has a leading less-than or greater-than sign which I'm trying to strip. This code doesn't seem to be working. Can anyone give me some pointers? Thanks much.

		IF (LEFT(@endPercentile, 1) = '<' OR LEFT(@endPercentile, 1) = '>') 
		BEGIN
			SET @endPercentile = RIGHT(@endPercentile, LEN(@endPercentile)-1)
		END

webfred
Flowing Fount of Yak Knowledge

Germany
8513 Posts

Posted - 06/29/2012 :  09:15:51  Show Profile  Visit webfred's Homepage  Reply with Quote
declare @test varchar(255)
set @test = '<bla'
if left(@test,1) in ('<','>')
begin
stuff (@test,1,1,'')
end


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47057 Posts

Posted - 06/29/2012 :  22:46:45  Show Profile  Reply with Quote
SET @endPercentile = STUFF(@endPercentile,1,CASE WHEN @endPercentile LIKE '<%' OR @endPercentile LIKE '>%' THEN 1 ELSE 0 END, '')

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8513 Posts

Posted - 06/30/2012 :  16:10:36  Show Profile  Visit webfred's Homepage  Reply with Quote
set @endPercentile = replace(left(replace(left(@endPercentile,1),'<','>'),1),'>','')


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000