Bharat Guru
asked on
SQL Server 2008 query analyzer adds trailing 0 in decimal field
When I try to execute below query analyzer in two different servers i'm getting two different results, What kind of setting could be different
Server 1
select myfield from tmytable
25
Server 2
select myfield from tmytable
25.0000000
Server 1
select myfield from tmytable
25
Server 2
select myfield from tmytable
25.0000000
May the two fields have different data types? Did you check that?
ASKER
both server are accessing data from same server same table same query
Can you post the exact query with some sample data?
ASKER
Data type is is [decimal](38, 18)
when I insert the value ast 15.1 in table it stores as 15.100000000000000000
how can I declare the field type which can stores max 18 decimal but when I add 15.1 is should store the actual value without leading 0s
when I insert the value ast 15.1 in table it stores as 15.100000000000000000
how can I declare the field type which can stores max 18 decimal but when I add 15.1 is should store the actual value without leading 0s
Just to clarify terms...
leading 0's = 00000000000000000000042.478
trailing 0's = 15.100000000000000000
leading 0's = 00000000000000000000042.478
trailing 0's = 15.100000000000000000
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One thing is how your data is stored and you can't do nothing with that unless you change the data type or precision for decimal fields.
Another thing is how you retrieve the data and for that you need to use the CAST or CONVERT function to achieve the format you want.
Another thing is how you retrieve the data and for that you need to use the CAST or CONVERT function to achieve the format you want.
Guessing Server 1 it's an int or character, and Server 2 it's something like numeric(9,7)