SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


rounding of decimals


rounding of decimals

Author
Message
skottikalapoodi
skottikalapoodi
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 Visits: 108
Hi,

I am trying to insert some records into another table. In this case i tried two methods

a. bulk inserting from a text file
b. inserting from a Sql Table

however when i am bulk inserting data from sql table one of decimal field value is getting rounding off

examle

source 1.57857

destination 1.5786 ....if i insert from sql table
destination 1.5785 ....if i bulk insert from text file

I want to insert data from Sql table only, but without rounding off of numbers...

can anybody help me please
Chandra Sekhara Vyas Dhara
Chandra Sekhara Vyas Dhara
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4209 Visits: 1149
If you datatype is money it will round off the 4th position after decimal.



skottikalapoodi
skottikalapoodi
Grasshopper
Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)Grasshopper (22 reputation)

Group: General Forum Members
Points: 22 Visits: 108
MY DATA TYPE IS DECIMAL ONLY.

ACTUALLY WHAT I WANT IS, I DON'T WANT IT TO BE ROUNDED
Madhivanan-208264
Madhivanan-208264
SSChasing Mays
SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)SSChasing Mays (649 reputation)

Group: General Forum Members
Points: 649 Visits: 476
skottikalapoodi (9/26/2008)
MY DATA TYPE IS DECIMAL ONLY.

ACTUALLY WHAT I WANT IS, I DON'T WANT IT TO BE ROUNDED

Can you post the table structure?



Madhivanan

Failing to plan is Planning to fail
bitbucket-25253
bitbucket-25253
SSCertifiable
SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)SSCertifiable (7.9K reputation)

Group: General Forum Members
Points: 7901 Visits: 25280
Remember what the definition of DECIMAL includes:
Precision is the number of digits in a number.
Scale is the number of digits to the right of the decimal point in a number.


For example:
DECLARE @Value DECIMAL(10,6)
DECLARE @Value2 DECIMAL(10,2)
DECLARE @Value5 DECIMAL(10,5)
SET @Value = 1.125456
SET @Value2 = @Value
SET @Value5 = @Value
SELECT @Value AS 'Scale of 6', @Value2 AS 'Scale of 2', @Value5 AS 'Scale of 5'
Results in:
Scale of 6 Scale of 2 Scale of 5
1.125456 1.13 1.12546

Check the definition of the column in your table to insure it has the correct scale value.

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)

Group: General Forum Members
Points: 87366 Visits: 41113
skottikalapoodi (9/26/2008)
MY DATA TYPE IS DECIMAL ONLY.

ACTUALLY WHAT I WANT IS, I DON'T WANT IT TO BE ROUNDED


DECIMAL WHAT??? What is the actual datatype of the column being imported into?Wink

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Matt Miller (4)
Matt Miller (4)
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12431 Visits: 18576
Assuming the data type is appropriate - you might have some luck forcing the Bulk insert or BCP to treat that column as a float through a format file (even if the actual destination column is not a float). That way - there's no attempt to round anything - it will just truncate instead.

----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search