Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 fields rounding up automatically

Author  Topic 

cable_si
Starting Member

20 Posts

Posted - 2011-10-31 : 08:37:16
Hi

I have a table like below, where col1 is a varchar column

table 1

col1
0.04
0.04
0.035
0.035
0.04

i want to transfer this information to another table using a select insert

each time i try and do this it automatically rounds up some of the values. i.e 0.035 becomes 0.04 I tried using CONVERT(DECIMAL(10,3),col1) which is ok for those values 0.035 but for the ones which say 0.04 it adds an extra 0 at the end to show 0.040
How can i get it so it inserts the data into a new table without the values in col1 being automatically rounded up or without extra 0's being added

thanks

Simon

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-10-31 : 08:55:02
What is the datatype for the new table and how are you transferring?
Are you sure that the data is being rounded on insert rather than display?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

cable_si
Starting Member

20 Posts

Posted - 2011-10-31 : 09:00:25
The datatype in both tables is a varchar(20)

data is transfered by

insert new_table
select col1 from table1
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-10-31 : 09:37:22
Think you should check your testing - I don't see how that can happen.
It can only round if it's being converted to a numerid datatype and that statement won't do that.

Maybe there is a trigger on the destination table?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -