Solved

Loss of precision using OpenQuery

Posted on 2004-09-07
3
671 Views
Last Modified: 2008-02-01
Hello,

I have created a function which returns records from a linked server using OPENQUERY (text file delimited with ';') into a TABLE variable.

CREATE FUNCTION [dbo].[fct_PremierTable_IMO]()
      RETURNS TABLE
AS
RETURN
(
      SELECT ZPRXSO, ZPRXVT, ZTVARV
      FROM OPENQUERY (IMO, 'SELECT * FROM IMMOS.txt')
)

The target Table variable is as follows:
DECLARE @tTable TABLE
(
                IDENTITE INT IDENTITY (1, 1) PRIMARY KEY NOT NULL,
          ZPRXSO DECIMAL(18,2),       ZPRXVT DECIMAL(18,2),       ZTVARV DECIMAL(18,2)
)

The problem is that the decimal part of the values are lost. For example, 2356 is obtained instead of 2356.58.
I have tried to use VARCHAR instead of DECIMAL without any success.

Please help!

Rishi
0
Comment
Question by:rrishi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 5

Accepted Solution

by:
g0rath earned 125 total points
ID: 11996585
cross platform work with decimal types can be hard, the simplest approach that works for me 100% of the time is to take the decimal type, multipy by 100 and transfer it as an integer type, then convert at my local point to decimal, money, float or whatever and just divide the set by 100.

Nothing is worse then 10.42 becoming 10.41999999 due to percision issues
0
 
LVL 18

Expert Comment

by:ShogunWade
ID: 11997154
what driver are you using in your linked server ?
0
 

Author Comment

by:rrishi
ID: 12003753
Thanks a lot, it seems to do the trick!
Im using OLEDB Jet 4.0 driver.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question