Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
T-SQL (SS2K5)
»
rounding of decimals
rounding of decimals
Rate Topic
Display Mode
Topic Options
Author
Message
skottikalapoodi
skottikalapoodi
Posted Friday, September 26, 2008 5:36 AM
Forum Newbie
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 2:36 AM
Points: 4,
Visits: 93
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
vyas
vyas
Posted Friday, September 26, 2008 6:11 AM
Hall of Fame
Group: General Forum Members
Last Login: 2 days ago @ 4:02 AM
Points: 3,131,
Visits: 1,056
If you datatype is money it will round off the 4th position after decimal.
Post #576722
skottikalapoodi
skottikalapoodi
Posted Friday, September 26, 2008 6:26 AM
Forum Newbie
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 2:36 AM
Points: 4,
Visits: 93
MY DATA TYPE IS DECIMAL ONLY.
ACTUALLY WHAT I WANT IS, I DON'T WANT IT TO BE ROUNDED
Post #576734
Madhivanan-208264
Madhivanan-208264
Posted Friday, September 26, 2008 7:08 AM
Old Hand
Group: General Forum Members
Last Login: Wednesday, September 12, 2012 5:17 AM
Points: 329,
Visits: 461
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
bitbucket-25253
bitbucket-25253
Posted Friday, September 26, 2008 7:29 AM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 9:21 AM
Points: 5,099,
Visits: 20,191
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
Jeff Moden
Jeff Moden
Posted Saturday, September 27, 2008 7:14 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 8:21 PM
Points: 32,893,
Visits: 26,765
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 "
R
ow-
B
y-
A
gonizing-
R
ow".
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."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #577358
Matt Miller (#4)
Matt Miller (#4)
Posted Saturday, September 27, 2008 9:47 PM
SSCertifiable
Group: General Forum Members
Last Login: Yesterday @ 1:56 PM
Points: 6,997,
Visits: 13,941
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 »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.