Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Calculation Colum

Author  Topic 

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2012-01-17 : 13:13:07
Hi Group:

Last Question of the day. I have a Colum that uses the enclosed type of data Sales_Loses_percentage = '-25.30%'.
I need to convert this data into an actual percentage field/column. So, what I need to do is eliminate the '%' sign and divide the -25.30/100 so I can have a result such as -2.530. How can I create the formula that eliminate the % sign and divide the numbers/100.

Thanks,

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-17 : 13:18:44
DECLARE @Sales_Loses_percentage varchar(25)
SET @Sales_Loses_percentage = '-25.30%'
SELECT CONVERT(decimal(15,4),REPLACE(@Sales_Loses_percentage,'%',''))


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

osirisa
Constraint Violating Yak Guru

289 Posts

Posted - 2012-01-17 : 13:25:33
Thank You very much Brett :)
Go to Top of Page
   

- Advertisement -