Friday, February 24, 2012

server to oracle doesn't fetch correct datavalues

I am using the open query method to connect a Oracle server.
Below is my code to connect to oracle,when I execute the same query in
oracle it fetches 199 rows whereas in Sqlserver it returns only 66 rows.
I have tried only one record based on id..sqlserver query returns 0
rows..whereas the oracle returns 4 rows..Can some one tell me what will be
the problem
SET QUOTED_IDENTIFIER OFF
declare @.sql varchar(750)
select @.sql = "SELECT * from openquery(PTTSTATUS," + '"' + "SELECT
A.PROJECT_ID,C.STATUS_NAME ,A.CNUMBER
FROM PTT.PTT_PROJECT A, PTT.PTT_STATUS C WHERE (C.STATUS_NAME IN ('Closed',
'Cancelled')) AND A.PROJECT_STATUS_ID = C.STATUS_ID AND A.CNUMBER is not null
ORDER BY A.CNUMBER
" + '")'
EXEC (@.SQL)
thanks
GP
Sorry I am connecting to two different databases.That's why the results are
different.
"GP" wrote:

> I am using the open query method to connect a Oracle server.
> Below is my code to connect to oracle,when I execute the same query in
> oracle it fetches 199 rows whereas in Sqlserver it returns only 66 rows.
> I have tried only one record based on id..sqlserver query returns 0
> rows..whereas the oracle returns 4 rows..Can some one tell me what will be
> the problem
> SET QUOTED_IDENTIFIER OFF
> declare @.sql varchar(750)
> select @.sql = "SELECT * from openquery(PTTSTATUS," + '"' + "SELECT
> A.PROJECT_ID,C.STATUS_NAME ,A.CNUMBER
> FROM PTT.PTT_PROJECT A, PTT.PTT_STATUS C WHERE (C.STATUS_NAME IN ('Closed',
> 'Cancelled')) AND A.PROJECT_STATUS_ID = C.STATUS_ID AND A.CNUMBER is not null
> ORDER BY A.CNUMBER
> " + '")'
> EXEC (@.SQL)
> thanks
> GP

No comments:

Post a Comment