I have an MS SQL query that retrieves data from a remote server. The data I pull should be filtered by the date that is determined at runtime. When I run the query as follows:
SELECT * FROM SERVER.Database.dbo.RemoteView WHERE EntryDate > '1/1/2009'
then the filter is applied remotely ... However, in fact, I do not want to use '1/1/2009' as a date - I want the date to be provided by a user-defined function, for example:
SELECT * FROM SERVER.Database.dbo.RemoteView WHERE EntryDate > dbo.MyCustomCLRDateFunction()
where the function is a custom CLR scalar function that returns the time of the date ... (You may ask why I need to do this ... the details are a bit complicated, so just trust me - I have to do it this way.)
When I run this query, the remote query is NOT filtered remotely - filtering is done after all the data has been pushed out (400,000 rows versus 100,000 rows), and this is significant.
Is there a way I can get the request to perform filtering remotely?
Thanks!
source share