Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    24

    Unanswered: ODBC Program & Heterogeneous queries problem

    Best All,

    What I am doing is following:
    1. I created a stored procedure "testit" which select records from another data source in another SQL Server, like:

    -------------------------------------
    SET ANSI_NULLS ON
    SET ANSI_WARNINGS ON
    go

    create procedure testit
    as begin
    select * from [AnotherSQLServer].bugtest.dbo.mssent
    end

    grant execute on testit to public
    -------------------------------------

    2. I can execute this stored procedure in SQL Query Analyser with success.

    3. BUT: now I write a ODBC program trying to call this stored procedure, then it give me following "famous" error:
    42000 [Microsoft][ODBC SQL Server Driver][SQL Server]Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.

    The ODBC program looks like this:
    -----------------------
    strcpy((char *) sqltext, "{call testit}");
    rc = SQLPrepare(hstmt, (unsigned char *) sqltext, SQL_NTS);
    rc = SQLExecute(hstmt);
    -----------------------

    My Question:
    1. Does ODBC API support Heterogeneous queries ?
    2. If well, how to solve above problem?

    Thanks a lot,

    Mel
    Last edited by Melvine; 09-03-03 at 11:00.

  2. #2
    Join Date
    Sep 2003
    Posts
    24

    solution

    The solution can be found here:

    http://dbforums.com/t905850.html

    use some thing like this (before calling SQLConnect() ):
    SQLSetConnectAttr( hdbc,SQL_COPT_SS_ANSI_NPW,(void *) SQL_AD_ON, 0);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •