Using OPENQUERY against a linked server in SSIS?

I'm trying something that should be simple. I want to set up a data refresh package using the SSIS Import and Export Wizard.
My source is Sage's MAS200 which is written on top of the ProvideX "DB" (a DBA's nightmare). Unfortunately, there is NO ProvideX ODBC driver that exposes column names although the tables names ARE available.
I'm forced to create a linked server and then use OPENQUERY to get at the data. So, something like SELECT * FROM OPENQUERY(LINKEDTABLE, 'SELCT * FROM AR_Division') works fine.
Now I'm trying to build an SSIS package. I'm using the .Net Framework Data Provider for ODBC to get to the source data and it works just as I've explained above. It shows me the tables but gives me know mapping information because it doesn't show me the columns.
So, I try the query approach, but the OPENQUERY can't be parsed.
Do any of you have any ideas?

If the query doesn't return valid metadata, then you won't be able to use it in the data flow.
Try this: Use the OPENQUERY in an Execute SQL task to populate a working table on the SQL Server side - something like :
Code Snippet
SELECT * INTO MyWorkingTable FROM OPENQUERY(LINKEDTABLE, 'SELCT * FROM AR_Division')
Then use a data flow to read the information from the working table and do any necessary transformations on it.
Thanks for this suggestion.  I was looking for help, with a similar issue and found this.
-Al H

Similar Messages

  • Can ODBC set by Instant Client be used in MS SQL linked Server?

    Hi:
    I want to know if a ODBC set by Instant Client can be used to set a linked server in MS SQL.
    I follow the install instruction about Instant Client.
    I create a ODBC setting and the connection tested successful.
    I also build it in DTS package in MS SQL and the data transfer process can be run correctly.
    But when I tried to build a linked server from MS SQL to oracle, it always returned the error message
    System1 Setting:
    MS Win 2003 + MS SQL 2000 + Instant Client 10.1.0.4
    System2 Setting:
    MS Win 2000 + Oracle 9.2
    Any opinion or suggestion is appreciated.
    Toni Lee

    with t_segment
    as
         select block_id, blocks, owner, segment_name,segment_type
           from dba_extents
          where tablespace_name = upper('&1')
          union all
         select block_id, blocks, 'sys' owner, 'Free' segment_name, 'FREE'
           from dba_free_space
          where tablespace_name = upper('&1')
          order by 1
    t_segment_1
    as
          select block_id,
              blocks,
              owner, segment_name, segment_type,
              owner||'-'||segment_name||'-'||segment_type seg
            from t_segment t
           order by 1
    select block_id, owner, segment_name, segment_type, sum(blocks) blocks
       from (select val block_id, owner, segment_name, segment_type,  blocks
            from (select block_id,
                   blocks,
                            owner, segment_name, segment_type,
                   seg,
                   row_number() over(order by block_id) rno,
                   nvl(lag(seg) over(order by block_id),' ') lag_seg
                 from t_segment_1)
           model
           return updated rows
           dimension by(rno)
           measures(block_id, blocks, seg, lag_seg, 0 val, owner, segment_name, segment_type)
           rules update
              val[any] = case when seg[cv()] <> lag_seg[cv()] then block_id[cv()] else val[cv()-1] end
      group by block_id, owner, segment_name, segment_type
      order by block_id

  • Instant client 10.2.0.3 used with ms sql linked server doesn't work

    Hi,
    instant client version 10.2.0.3 doesn't work as microsoft sql linked server (both 2000, 2005) while 10.2.0.1 does. (tested by overwriting files in instant client directory - basic instalation, then restart mssql services) - the message is, that the oracle client is not installed when running sql (registration of linked server is ok).
    Is it a known issue or is there any workaround?
    (Windows XP, 2003, MS SQL 2005, MS SQL 2000, Oracle 9.2.0.6)
    Thanks,
    Pavel

    I installed oracle-instantclient-basic-10.2.0.3-1.i386.rpm on a redhat box to
    connect oracle database server 9.2.0.8.0 install on win box.Is there any other Oracle software installed on the RedHat machine?
    In which directory did you install Instant Client?
    Can you login with sqlplus?
    On the database server, I defined parameters like this :
    NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
    NLS_NUMERIC_CHARACTERS='. 'This will have no effect on your problem - these are client environment variables.
    Before starting apache (lampp) I set Oracle environement like this :
    export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
    export NLS_NUMERIC_CHARACTERS='. '
    My application worked very fine.
    BUT a few days ago (1 week), in my application, the date format display wrong,
    I have this format : DD/MON/YYYY even with
    export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
    before starting apache.The ancient question: Do you remember what you changed before it stopped working?
    So I stop my apache and try set Oracle environment like this :
    export ORACLE_HOME=/usr/lib/oracle/10.2.0.3/clientAs has been said, do away with that.
    export PATH=$ORACLE_HOME/bin:$PATHYou don't need that either.
    Except is might be nice to have the directory that contains sqlplus in PATH.
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATHNow that surprises me.
    Normally, instant client shared libraries are not installed in a subdirectory.
    Does this "lib" directory exist?
    You should add the directory containing the *.so files to LD_LIBRARY_PATH.
    When I restart apache and test my application, an error php message occurs :
    Ocisessionbegin error while trying TO retrieve text FOR error ora-12705
    I check my oracle_home, I don't think I make a mistake?It seems that Oracle cannot find the instant client shared library libociei.so.
    This library must be found in LD_LIBRARY_PATH.
    In this context it would be interesting to know (as I asked above) if any other Oracle products are installed on this machine.
    Yours,
    Laurenz Albe

  • Ms sql server linked server with OraOLEDB.Oracle provider session handling

    Hi everyone!!
    Here's my situation:
    I have a MS SQL Server 2008 R2 with a linked server to Oracle via OraOLEDB.Oracle provider.
    I use a .net application to open a connection to my sql-server, execute a select that collects data through the linked-server-connection from the oracle database and after that I close to connection to the sql.
    It does work so far,
    but when I start my application, exit it proberly and start it again it seems that i get the same session as before (which is for some reasons very bad).
    Is that the right/normal behavior?
    Is there any way to avoid that?!
    How does the OraOLEDB.Oracle provider handle the sessions if used in/as a linked server?
    thanks and greetings,
    exoc
    Edited by: 944414 on Jul 4, 2012 5:43 AM

    Hii Rouann,
    Does the error occur when you call the stored procedure from SSIS package and map SSIS variables to the parameters in the stored procedure? Can you run the store procedure from SSMS properly? If you can run the stored procedure from SSMS, the issue seems
    to occur due to the date format mismatch between the SSIS variables and the parameters in the stored procedure.
    If you cannot run the stored procedure from SSMS as well, the issue should occur due to the incorrect data conversion within the store procedure itself as Tom mentioned.
    Regards,
    Mike Yin
    TechNet Community Support

  • SQL 2005 Linked server to Oracle append

    Hi Oracle Exprets,
    i am using an SQl 2005 linked server too pull data from specific table in Oracle data base.
    the thing is i have to pull data daily and append this data to the exsisting table.
    here is my code :
    EXEC sp_tables_ex @table_server ='LINKED_ORA',@table_schema='Myschema'
    INSERT INTO dbo.ARS20091
    SELECT * FROM OPENQUERY(LINKED_ORA,
    'SELECT
    TROUBLEID,
    CREATE_DATE,
    DATE ''1970-01-01'' + CREATE_DATE / 24 / 60 / 60
    CREATEDATE
    FROM CLIENT_TROUBLE
    WHERE CREATE_DATE between ''1230768001'' AND ''1239043005''');
    GO
    this code works but i have to change the date daily and do a complete insert in a new table.
    Is there a way to append data daily ?
    thanks

    Hi sanjay,
    but why sysdate is giving me the today's date and when i use getdate ...it does not give me anything..
    i am using openquery tooracle data base..usually i have to use Oracle command..
    Mo..

  • LINKED SERVER ISSUE on ORACLE DATABASE

    Hi everyone
    I have SQL 2008 R2 Running on Windows server 2003 R2 OS.
    I have created a linked server to ORACLE 11
    I have may jobs running process against this linked server and thy work fine
    But soddenly I receive this error :
    Cannot initialize the data source object of OLE DB provider "OraOLEDB.Oracle" for linked server "WMS". [SQLSTATE 42000] (Error 7303).  The step failed
    In this scenario the SQL SERVER AGENT Account is the Domain administrator.
    When I restart the Server it begin to work fine again but from time to time I receive again the error mentioned above.
    Have any one pass through this issue?

    Is the network connection to Oracle box stable? Is it inside a firewall?
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Installing OLEDB Provider (10.2.0.3) for use in creating SQL Linked Servers

    I've installed the Oracle OLEDB Provider (version 10.2.0.3) on my SQL Server 2005 box (Windows 2008 64-bit). However, when I reboot the server after install I do not see the OraOLEDB.Oracle provider in my list of providers available to use to create a linked server to the Oracle database.
    Could someone help steer me in the right direction?
    Thanks!!

    Hi,
    This forum is for links from Oracle to non-Oracle databases. For issues with connectivity to Oracle using ODBC/OLEDB it would be better to ask the question in the ODBC forum -
    ODBC
    They have the experience of connections to Oracle and the software involved.
    Regards,
    Mike

  • Unable to create a linked server that points to an availability group listener.

    I don't even know if this scenarios is supported or not, I can't find any documentation on it.
    I have a couple SQL 2012 servers setup using AlwaysOn Availability Groups.  The listener (SQLAG1) is setup and working as expected with applications.   The 2 machines are in different subnets, so we are using the MultiSubnetFailover=True on the
    connection strings to ensure that failover works. 
    From an SQL 2014 box I want to create a linked server that points at the Listener.   I'm able create the linked server, but it appears like sql server is not using the MultiSubnetFailover=True and it fails to connect.  Here is what I used to create
    the linked server;
    EXEC sp_addlinkedserver
    @server = N'SQLAG1',
    @srvproduct = N'SQL2012',
    @provider = N'SQLNCLI11',
    @datasrc = N'SQLAG1',
    @provstr = N'Provider=SQLNCLI11.1;Data Source=SQLAG1;MultiSubNetFailover=True',
    @catalog = NULL
    GO
    Do anyone know if this is supported?  if so what it proper way to create the linked server?  
    Thanks!!!

    Thank you.   
    OLE DB in the SQL Server Native Client does
    not support the MultiSubnetFailover keyword.

  • User created SQL Agent Job that uses linked server with Windows authentication

    OK, here's what I want to do, but not sure exactly what I need to accomplish it.
    Environment
    Windows 2008 Enterprise
    SQL 2012 Enterprise
    SQL Server & SQL Agent running under AD account (which has local Windows Administrative privileges...yes, I know..bad!)
    Linked server to Teradata utilizing AD account mappings (the linked server works successfully and each windows login is mapped to a Teradata LDAP login)
    Requirement
    Allow non sysadmins to create SQL Agent jobs which execute TSQL statements which use OPENQUERY(LDAPLinkedServer, '....) syntax
    I've already given the non sysadmins the necessary permissions to create and run SQL Agent jobs, and I understand that the jobs run under their login context, but I suspect that I'm missing something when it comes to the linked server.
    Each windows user could have access to different databases/tables on the Teradata system that even I (the SQL Server sysadmin) don't have access to.
    How can I facilitate this functionality?  Any ideas?

    I think I may have been over complicating the Teradata piece.  The authentication methodology in Teradata is LDAP, which just means that it authenticates against AD, but you still have to submit your Windows login & password.  It doesn't automatically
    authenticate you just because you're logged into Windows.  
    The linked server has the mapping for the individual windows logins like:
    Local Login = <domain>.<windows id>
    Remote User = <windows id>
    Remote Password = <windows password>
    This setup requires the user to have to change the passwords in the linked server whenever they change their passwords according to domain policy (every xx days)...but we've created a utility proc that they can use to do this.
    So, I'm thinking that Teradata isn't really part of this equation.

  • Running a SSIS package with SQL Job and Linked Server

    I have a SSIS 2008 package. In one of the Script task I am calling a stored procedure which is  using Openquery using linked server. I deployed this package with protection level as "EncryptWithPassword" and gave a password to the package.
    Created a SQL job and edited its command line to include the password. If I login to SQL Server Mgmt Studio with Windows Authentication and run the job manually it runs fine. But when I schedule it then I get an error that "The Communication link to Linked
    server failed".
    Please help 

    Hi Vivek.B,
    The issue should occur because the SQL Server Agent Service Account or SQL Agent Proxy account under which the job step runs doesn’t have sufficient permissions on the linked server.
    If the job owner is the sysadmin fixed server role, the job can be run under the SQL Server Agent Service Account or a proxy account, then please make sure the SQL Agent Service Account or the proxy account has corresponding login on the linked server. If
    the job owner is not a sysadmin fixed server role, the job must run under a proxy account. In this case, make sure the proxy account has a corresponding login on the linked server.
    Reference:
    http://blogs.msdn.com/b/dataaccesstechnologies/archive/2009/10/13/who-owns-my-job-and-who-runs-it.aspx
    Regards,
    Mike Yin
    TechNet Community Support

  • Specifying a Linked Server as parameter/environment in a 2012 SSIS project

    I have a server that will hold the 2012 SSIS projects which I want to run against the AlwaysOn Listener. How do I to specify the linked server in a parameter? If I just use a server parameter that matches the Linked Server name will that work?
    Just to mention in SSIS SSDT when specifying the server and pointing to the Listener all the databases appear in the database dropdown but when specifying a node only the non-AlwaysOn databases appear. Weird?

    Porjects or packages?
    Linked Server? Why?
    Is your intent is connecting to a read-only secondary?
    A name of the server instance that is primary is enough. For read-only replicas you need the connection string amended to include
    applicationintent=readonly
    All the database supposed to appear that are part of the instance you are connecting to.
    Arthur My Blog

  • How to create a view on SQLServer 2008 as an OPENQuery select to a MYSQL linked server

    I am trying to create a view on SQLServer through Management Studio based on data on a MYSql server.
    I have created the Linked server and I am able to query all data.
    Using the syntax select * from OPENQUERY (linkedServer, 'select * from MYSQL-table') - This works fine
    What I am trying to do now is issue the following statement
    create view ViewnameToBeCreatedOnSQLServer
       as select * from OPENQUERY (linkedServer, 'select * from MYSQL-table')
    When I run this from SSMS I get the following error
    OLE DB provider "MSDASQL" for linked server "TESTTSC2" returned message "[MySQL][ODBC 5.1 Driver][mysqld-5.0.95-log]Table 'FP.M3' doesn't exist".
    Msg 7350, Level 16, State 2, Procedure FPMaster3, Line 2
    Cannot get the column information from OLE DB provider "MSDASQL" for linked server "TESTTSC2".
    The account I am using has create view privs and alter schema privs on the SQlServer side. I am assuming there are not isues on the MYSQL server side since I am able to successfully run the select statement using OPENQUERY.  There must be one small
    piece I am missing. has anyone experienced the same problem and were you able to find a solution?

    All the configurations seem to be in place correctly since I can SELECT any data with no issues. The statement   
    select * from OPENQUERY (linkedServer, 'select * from MYSQL-table')
    works fine and I can change the table I am selecting from which all return data. Therefore, the objects all exists in MYSQL.
    The DSN is set up, the linked Server is good, the provider is set up, the DB account has all privs.
    It only fails when I try to create the view on SQLServer as a select from a remote table accessed via the linked MYSQL server. I connect to SQLServer with DB account PS which has full privs including CREATE VIEW and ALTER SCHEMA. The MYSQL pass-through account
    has read access to all objects in the MYSQL schema. I am trying to figure out if I might be missing some little part of this puzzle when trying to create a new object (CRESTE VIEW) vs. just reading the data (SELECT).
    The kicker in all this is that I did create a view on SQLServer in this manner about a year ago and I am able to see the view definition and that view still works! So, this is quite interesting that I am not able to create a new object.
    If there any specific information I could provide which might help, I am happy to do that. Just did not want to provide the details on all of the puzzle pieces if it can be avoided but if it comes to that then that's OK also.
    Thanks very much! I appreciate your help.

  • Error: An error occurred while preparing the query in openquery on ServiceNow ODBC Link Server

    Hi Team,
    Greetings of the Day!!!!!
    I have a created a link server on SQL Server 2008 R2 databse of Service Now ODBC driver. And written a stored procedure using openquery to get the data from link server.
    Now problem is that, when i have scheduled that stored procedure in sql jobs. When this job runs automatically then we are getting below error while when i start the job mannually then it's not giving error.
    An error occurred while preparing the query "..........."
    Please help me to resolve this issue.
    Regards,
    Brijendra Pandey

    Hi Fanny,
    I had reviewed the job history. I am getting below message where as table is exist in the database.
    Message
    Executed as user: NT AUTHORITY\SYSTEM. OLE DB provider "MSDASQL" for linked server "SNOWDSN" returned message "[DataDirect][ODBC OpenAccess SDK driver][OpenAccess SDK SQL Engine]Base table:incident not found.[10129]". [SQLSTATE 01000] (Message 7412)  OLE
    DB provider "MSDASQL" for linked server "SNOWDSN" returned message "[DataDirect][ODBC OpenAccess SDK driver][OpenAccess SDK SQL Engine]Base table:sysapproval_approver not found.[10129]". [SQLSTATE 01000] (Message 7412)  OLE DB provider "MSDASQL" for linked
    server "SNOWDSN" returned message "[DataDirect][ODBC OpenAccess SDK driver][OpenAccess SDK SQL Engine]Base table:problem not found.[10129]". [SQLSTATE 01000] (Message 7412).  The step succeeded.
    Regards,
    Brijendra Pandey

  • Problem in Using Time Stamp when Querying from SQl Server to ODBC linked server

    I am using Following Query for my subject pupose but facing different Issues, Error Also shown after Query
    Query IS:
    DECLARE @sql varchar(8000)
    SELECT @sql = 'SELECT * FROM OPENQUERY(TEST, ' +
                  '''SELECT * FROM SCHEMA.OAUSER.Tag_Value ' +
                  'WHERE Tag_id = ''''GROUP_1SEC.COOLING_TOWERS.MOTORS.AG001.CURRENT.CV'''''+
                  ' AND timestamp = ''''{ts ''''2014-z02-18 15:28:38'''' }'''''')'
    PRINT @sql
    EXEC(@sql)
    And i am getting this Error:
    OLE DB provider "MSDASQL" for linked server "TEST" returned message "[DataDirect][OpenAccess ODBC]Syntax error in SQL statement. syntax error line 1 at or after token <2014>.".
    Msg 7321, Level 16, State 2, Line 1
    Please Guide me.
    Regards;
    Siraj

     Sorry "Z" was written by mistake
    I am using :
    DECLARE @sql varchar(8000)
    SELECT @sql = 'SELECT * FROM OPENQUERY(TEST, ' +
                  '''SELECT * FROM SCHEMA.OAUSER.Tag_Value ' +
                  'WHERE Tag_id = ''''GROUP_1SEC.COOLING_TOWERS.MOTORS.AG001.CURRENT.CV'''''+
                  ' AND timestamp = ''''{2014-02-18 15:28:38}'''''')'
    PRINT @sql
    EXEC(@sql)
    And Getting this error:
    OLE DB provider "MSDASQL" for linked server "TEST" returned message "[DataDirect][OpenAccess ODBC]Error getting the literal value of right operand.".

  • Query using link server to an Oracle database failswhile similar query works

    I have two queries almost the same that use a link to an Oracle database. One works ok, the other is a copy of the first with a few fields selects removed.  The first one works fine, the copy fails with: Cannot get the data of the row from the OLE DB
    provider "OraOLEDB.Oracle" for linked server "linkname".
    They are so similar, why would one work but not the other? 
    First query, this one works:
    SET
    ANSI_NULLS ON
    GO
    SET
    QUOTED_IDENTIFIER ON
    GO
    CREATE
    PROCEDURE [dbo].[procedure_name]
    -- Add the parameters for the stored procedure here
    @Begindate  Datetime,
    @Enddate Datetime
    AS
    BEGIN
    --SET NOCOUNT ON added to prevent extra result sets from
    --interfering with SELECT statements.
    SET NOCOUNT
    ON;
    -- Insert statements for procedure here
    select p.patientid, p.testid,
    mdx."Dx_4", td.acquisitiondatetime_dt, td.democompletedatetime_dt,
    td.editdatetime_dt,
    CAST(STUFF(STUFF(mn."Arrival_Time_9",
    9, 0,
    ' '), 12, 0,
    AS datetime)
    as Arrival_date,
    CAST(STUFF(STUFF(mt."Comp_D_T_22",
    9, 0,
    ' '), 12, 0,
    AS datetime)
    as Order_date, td.confirmdatetime_dt
    (CAST(DATEDIFF
    (MINUTE,
    CAST (STUFF
    (STUFF
    (MN."ARRIVAL_TIME_9", 9,0,
    ' '), 12, 0,
    AS DATETIME), TD.DEMOCOMPLETEDATETIME_DT) 
    as char(10))
    + 'min')
    AS "ARRIVAL TO COMPLETE",
    (CAST(DATEDIFF
    (MINUTE,
    CAST (STUFF
    (STUFF
    (MT."COMP_D_T_22", 9,0,
    ' '), 12, 0,
    AS DATETIME), TD.DEMOCOMPLETEDATETIME_DT)
    as char(10))
    + 'min') 
    AS "ORDER TO COMPLETE"
    from linknametosqldb.sqldbname.dbo.tstpatientdemographics
    as p inner
    join linknametosqldb.sqldbname dbo.tsttestdemographics
    as td on p.testid
    = td.testid
    left
    outer join linknametooracledb."M01Tab01_Main" mn
    on td.visitnumber
    = mn."Pt_Acct_5"
    inner
    JOIN linknametooracledb."M01Tab06_Ord" mt
    ON mn."Master_Recid_1"
    = mt."Master_Recid_1"
    inner
    join linknametooracledb."M01Tab09_Dx" mdx
    on mn."Master_Recid_1"
    = mdx."Master_Recid_1"
    where td.location
    in (2, 4)
    and mt.order_4
    like 'EKG%' 
    and mdx."Dx_4"
    like '%Chest Pain%'
    and
    (td.acquisitiondatetime_dt
    >= @Begindate and td.acquisitiondatetime_dt
    < @Enddate)
    order
    by p.patientfullname_last, p.patientfullname_first
    END
    GO
    Second query, copied from first with some fields selects removed, this does not work:
    SET
    ANSI_NULLS ON
    GO
    SET
    QUOTED_IDENTIFIER ON
    GO
    CREATE
    PROCEDURE [dbo].[procedure_name_2]
    -- Add the parameters for the stored procedure here
    @Begindate  Datetime,
    @Enddate Datetime
    AS
    BEGIN
    --SET NOCOUNT ON added to prevent extra result sets from
    --interfering with SELECT statements.
    SET NOCOUNT
    ON;
    -- Insert statements for procedure here
    select p.patientid, mdx."Dx_4",
    td.democompletedatetime_dt,
    CAST(STUFF(STUFF(mn."Arrival_Time_9",
    9, 0,
    ' '), 12, 0,
    AS datetime)
    as EDIS_Arrival_date,
    (CAST(DATEDIFF
    (MINUTE,
    CAST (STUFF
    (STUFF
    (MN."Arrival_Time_9", 9,0,
    ' '), 12, 0,
    AS DATETIME), TD.DEMOCOMPLETEDATETIME_DT) 
    as char(10))
    + 'min')
    AS "ARRIVAL TO COMPLETE"
    from linknametosqldb.dbo.tstpatientdemographics
    as p inner
    join linknametosqldb.dbo.tsttestdemographics
    as td on p.testid
    = td.testid
    left outer
    join linknametooracledb."M01Tab01_Main" mn
    on td.visitnumber
    = mn."Pt_Acct_5"
    inner
    JOIN linknametooracledb."M01Tab06_Ord" mt
    ON mn."Master_Recid_1"
    = mt."Master_Recid_1"
    inner
    join linknametooracledb M01Tab09_Dx" mdx
    on mn."Master_Recid_1"
    = mdx."Master_Recid_1"
    where td.location
    in (2, 4)
    and mt.order_4
    like 'EKG%' 
    and mdx."Dx_4"
    like '%Chest Pain%'
    and
    (td.acquisitiondatetime_dt
    >= @Begindate and td.acquisitiondatetime_dt
    < @Enddate)
    order
    by p.patientid
    END
    GO
    Thanks very much for any help with this.

    * Consider putting parentheses around the 3 oracle tables so the 3 of them can possibly be treated as a unit.  Assuming there's some performance impact due to the linked server, this MIGHT help, may do a little joining over on the Oracle side of
    the world.  In either case, it's a little cleaner.  They syntax below, including a few extra line breaks for clarity, should be correct.  (try the change to the ON clause suggested above too, though).
    The parentheses will not help much. SQL Server will remote (as the term is) the query to the Oracle instance if this appears to have a lower cost and there is nothing the blocks remoting.
    On the other hand, OPENQUERY can be an alternative to ensure that this happens:
     left outer join
        OPENQUERY (linknametooracledb,
                   'SELECT ...
                    FROM   "M01Tab01_Main" mn
                    JOIN   "M01Tab06_Ord" mt ON mn."Master_Recid_1" = mt."Master_Recid_1"
                    JOIN   "M01Tab09_Dx" mdx on mn."Master_Recid_1" = mdx."Master_Recid_1"') mn on td.visitnumber = mn."Pt_Acct_5"
    But this presumes that you there are no columns from the SQL Server side that are used to select data from the Oracle side. That is, the above could lead to far much data being brought across the wire.
    Then again, this does not really seem to relate to the original problem where a stored procedure was not working at all. That problem is not very easy to assist with since code post is the not the authentic code as pointed out in the thread. For instance
    inner JOIN linknametooracledb."M01Tab06_Ord"
    Has nothing to do with Oracle, but accesses a table in the schema linknametooracledb.
    I think to help dmcm, you need a really good crystal ball - at least as long he/she does not share the actual code.
    Erland Sommarskog, SQL Server MVP, [email protected]

Maybe you are looking for