Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

rounding of decimals Expand / Collapse
Author
Message
Posted Friday, September 26, 2008 5:36 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 28, 2014 10:50 AM
Points: 4, 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


Post #576692
Posted Friday, September 26, 2008 6:11 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Monday, November 24, 2014 3:22 AM
Points: 3,906, Visits: 1,098
If you datatype is money it will round off the 4th position after decimal.


Post #576722
Posted Friday, September 26, 2008 6:26 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 28, 2014 10:50 AM
Points: 4, Visits: 108
MY DATA TYPE IS DECIMAL ONLY.

ACTUALLY WHAT I WANT IS, I DON'T WANT IT TO BE ROUNDED
Post #576734
Posted Friday, September 26, 2008 7:08 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, May 23, 2014 5:59 AM
Points: 329, Visits: 470
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
Post #576794
Posted Friday, September 26, 2008 7:29 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, November 6, 2014 1:00 PM
Points: 5,333, Visits: 25,277
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
Post #576825
Posted Saturday, September 27, 2008 7:14 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:51 PM
Points: 35,606, Visits: 32,190
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?;)


--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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #577358
Posted Saturday, September 27, 2008 9:47 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 10:30 AM
Points: 7,154, Visits: 15,647
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?
Post #577370
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse