Link to home
Start Free TrialLog in
Avatar of Steve A
Steve AFlag for United States of America

asked on

Search for a decimal and then remove it from string

Hello,
I need a T-SQL Statement to search a string variable for a decimal and
then remove it.

@string = '1234.5'

I want @string to equal '12345'

If I do it this way:
Set @string = replace(@string, '.', '')

I would assume it would remove the decimal in the string.

What if @string = '12345', with no decimal?

Would it not work and set @string = NULL, due to not finding a decimal within the
replace statement?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Chris__W
Chris__W
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of EugeneZ
EugeneZ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve A

ASKER

thanks for the information and decided to leave it as it is and it took out the decimal, as stated, thanks