# Thread: Convert real to Varchar.

1. Registered User
Join Date
Nov 2003
Location
NJ USA
Posts
19

## Unanswered: Convert real to Varchar.

Hello All,

I am facing problem to get exacltly value using convert function. Please follow below steps.

Crete table A (ID Real)

Insert into A values(0.0013)

select convert(varchar, convert(DECIMAL(30,6), id)) from A

----------------
0.001300

I am getting '0.001300' values because scale is 6 in Decimal so that is why I am getting but want to get '0.0013' values. Please let me know

2. Window Washer
Join Date
Nov 2002
Location
Jersey
Posts
10,322
HEY NJ!

isn't it "Jersey"?

Doesn't this work?

Code:
```USE Northwind
GO

CREATE TABLE A ([ID] Real)
GO

INSERT INTO A ([ID]) values(0.0013)

SELECT CONVERT(varchar(45), [ID]) FROM A
GO
DROP TABLE A
GO```

3. Registered User
Join Date
Nov 2003
Location
NJ USA
Posts
19

## Convert real to Varchar.

Hello All,

I am facing problem to get exacltly value using convert function. Please follow below steps.

Crete table A (ID Real)

Insert into A values(0.000013)

select * from a

Ouput
-------------------
1.13 e05

But I want '0.000013' to display so that is why I have written below Query.

select convert(varchar, convert(DECIMAL(30,6), id)) from A

----------------
0.00001300

I am getting '0.001300' values because scale is 6 in Decimal so that is why I am getting but want to get '0.0013' values. Please let me know

---- Is any function using that I can remove added/padded zero suffix.

Current Expected result.
0.00001300 to 0.000013

4. Window Washer
Join Date
Nov 2002
Location
Jersey
Posts
10,322
Did you try what I gave you?

5. Registered User
Join Date
Feb 2002
Posts
2,232
You use 2 different numbers:

0.0013 and 0.000013 - which one is it ?

If it is the first then just change the decimal from 6 to 4.

6. Window Washer
Join Date
Nov 2002
Location
Jersey
Posts
10,322
Does the precision matter if you're going to varchar?

And I still want to know

What exit?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•