sql-server-2008bulk-import

My values in money column are changed when bulk insert is used


I have a table where I store amount in money. When I used to insert these values from my that table to another table; values changes.

In my first table value of a column 'PRICE' is 130 but when bulk insert was used, it was inserted as 129.60 in another table.

My bulk insert command is:

Insert into InvoiceDetail(InvoiceId,AgentId,ProductCode,BrandId,Qty,Price,ProductType)
 Select SCOPE_IDENTITY(),'12736387',ProductCode,BrandId,Qty,M2CPrice,ProductType from 
UserPackages where AgentId='12736387'

Solution

  • I would recommend you to use decimal/numeric instead of money as money is not precise. You can check Should you choose the MONEY or DECIMAL(x,y) datatypes in SQL Server?

    Do note that MONEY data type has rounding errors. Also performance wise decimal is better. Check the blog by Aaron Bertrand: Performance / Storage Comparisons : MONEY vs. DECIMAL