Solved

Loss of precision using OpenQuery

Posted on 2004-09-07
3
664 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL 10 35
Upgrading my SSIS package in VS 2012 6 59
SQL Server 2012 Database Restore 4 38
SQL Activity Monitor detail 2 24
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

808 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