Converted data with NUMBER in Oracle to NUMERIC in SQL Server with openquery

352 Views Asked by At

I have a linked server to Oracle database in SQL server and retrieve data to local SQL server database every day by scheduling, the problem is: one of the Oracle database column has holding number with 18 fixed digits which type is NUMBER(18) and when I am trying converting that column to numeric(18,0) or numeric(38,0) and so on, the data converted but for many of them, last digit is different with source data, for example:

data in Oracle database(source): 100002345678912345

data in SQL database (destination): 100002345678912348

1

There are 1 best solutions below

0
Hassan Hosseini On BEST ANSWER

Thanks to @Jeroen Mostert. I used DBCC TRACEON (7314) before INSERT INTO and my data is changed to DOUBLE type, after that to solve the problem I used SELECT CAST(COLUMN_NAME AS numeric(18,0))

for example:

My Real Data:100002345678912345

My Data (wrong data): 100002345678912348

My Data after using DBCC TRACEON (7314): 100002345678912345.0000000000

My Data after using SELECT CAST(COLUMN_NAME AS NUMERIC(18,0)): 100002345678912345