Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Filtering records in OpenQuery

Author  Topic 

Francis
Starting Member

2 Posts

Posted - 2002-11-12 : 03:30:42
Hi,

I am using "Linked Servers" concept to import data from an Oracle database into SQL Server. The following is an example

INSERT INTO tblTable
(Field1, Field2)

SELECT *
FROM OPENQUERY(OraTest, '

SELECT DISTINCT Field1,
Field2

FROM tblAnotherTable

')
GO


Question : Is there any way to send down a filter to Oracle saying that I only want records that were added yesterday? I want this filtering process to be done at the Oracle level rather than pull the entire set of records and then filter it at my level.

Any help will be appreciated.

Thanking you.

cheers
Francis

Andraax
Aged Yak Warrior

790 Posts

Posted - 2002-11-12 : 03:52:54
If you do the filtering in your query:

SELECT DISTINCT Field1,
Field2
FROM tblAnotherTable
WHERE <conditions>

The query is sent to the oracle server and processed there, so there will be no unneccesary traffic.


Go to Top of Page

Francis
Starting Member

2 Posts

Posted - 2002-11-12 : 04:15:04
Thanks for the answer Andraax

The where clause is fine. But the problem lies in the fact that I would need to hardcode the filter. In cases eg date, which changes everyday the filter cannot be built up via code and then sent down to Oracle.
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2002-11-12 : 04:20:26
quote:

Thanks for the answer Andraax

The where clause is fine. But the problem lies in the fact that I would need to hardcode the filter. In cases eg date, which changes everyday the filter cannot be built up via code and then sent down to Oracle.




Then you need a function like the datediff function, just ask for all the entries where the date is one day different from the current date. Oracle should be able to provide you with that.

Go to Top of Page
   

- Advertisement -