dimitri / pgloader

Migrate to PostgreSQL in a single command!
http://pgloader.io
Other
5.35k stars 541 forks source link

Transforming MS-SQL money datatype to PostgreSQL numeric(19, 4) datatype. #1582

Open olegrost opened 4 months ago

olegrost commented 4 months ago

When loading from ms-sql, the values in columns of the money type are distorted. Source data (ms): price (money) prc (money) 296685,43 0,6116

  1. What I did:

LOAD DATABASE from mssql://user:password@mssqlserver/src_db into pgsql://user:password@pgserver/trg_db

WITH create no tables, include no drop, data only, truncate SET PostgreSQL PARAMETERS maintenance_work_mem to '4096000', work_mem to '16384' INCLUDING ONLY TABLE NAMES like 'Tbl_To_Load' in SCHEMA 'dbo' ALTER SCHEMA 'dbo' RENAME TO 'shc';

  1. result I got Dest data (ms): price (money) prc (money) 296685,44 0,6116

  2. how the result is not what you expected. The result is different due to incorrect rounding of the source datatype "money" (before converting to the destination type numeric for PostgreSQL) to 2 decimal places. After using the #1494 I got the following result: Dest data (ms): price (money) prc (money) 296685,43 0,61

What do I need to do to get an exact copy of the money datatype values from MS_SQL Server? Thank you!