OPENQUERY results....
From: DylanM (DylanM_at_discussions.microsoft.com)
Date: 09/01/04
- Next message: Graeme Malcolm: "Re: Script help please"
- Previous message: Simon Jefferies: "Restoring a database"
- Next in thread: oj: "Re: OPENQUERY results...."
- Reply: oj: "Re: OPENQUERY results...."
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 1 Sep 2004 02:23:07 -0700
Can someone please explain this one to me...!
I have a linked server from a SQL 2000 server to an IBM AS/400. I'm issuing
a query against the linked server and have tried to place the WHERE clause
inside the OPENQUERY SQL statement.
When I do this, it only returns 1 record...
1 Record Returned SQL Syntax
SELECT * FROM OPENQUERY(LS_W1CENTRALORDERS, 'SELECT A.PRDPK, A.PRDART,
A.PRDTIT, A.PRDDTP, A.PRDSDP, A.PRDCLS, A.PRDSUP, A.PRDREC, A.FMTDRT,
A.FMTCAT, A.FMTDES, A.FMTRT1, A.FMTFTM, B.COFADD, A.FMTDPR, A.FMTSOR,
A.FMTCAT, B.COFQTY, B.COFSKF, B.COFFMT, B.COFTSK, C.COACTC FROM
UKHOFQRY.CISCODTAL1 A, QAHOFLIB.COFMTPF B, QAHOFLIB.COARTPF C WHERE A.FMTPK =
B.COFSKF AND A.PRDPK = C.COASKU AND A.PRDPK = 654090')
When I issue the same statement, but with the where clause in the outer
section, it returns 2 records (which is correct)
2 Records Returned SQL Syntax
SELECT * FROM OPENQUERY(LS_W1CENTRALORDERS, 'SELECT A.PRDPK, A.PRDART,
A.PRDTIT, A.PRDDTP, A.PRDSDP, A.PRDCLS, A.PRDSUP, A.PRDREC, A.FMTDRT,
A.FMTCAT, A.FMTDES, A.FMTRT1, A.FMTFTM, B.COFADD, A.FMTDPR, A.FMTSOR,
A.FMTCAT, B.COFQTY, B.COFSKF, B.COFFMT, B.COFTSK, C.COACTC FROM
UKHOFQRY.CISCODTAL1 A, QAHOFLIB.COFMTPF B, QAHOFLIB.COARTPF C WHERE A.FMTPK =
B.COFSKF AND A.PRDPK = C.COASKU')
WHERE PRDPK = 654090
The second query runs much slower, I assume this is because it's selecting
all records in the table first (approx 300k) , then selecting out those that
meet the criteria?
Why would the results be different tho, if there are 2 records that meet the
criteria surely the first statement should also return them?
Confused....!
Thanks
- Next message: Graeme Malcolm: "Re: Script help please"
- Previous message: Simon Jefferies: "Restoring a database"
- Next in thread: oj: "Re: OPENQUERY results...."
- Reply: oj: "Re: OPENQUERY results...."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|