Filter predicate with sliding window

As mentioned earlier, you cannot call a non-deterministic function in a filter predicate. If you, for instance, want to migrate all rows older than 1 month (where a date column has a value older than 1 month), you cannot simply use the DATEADD function in the filter function because DATEADD is a non-deterministic function.

In the previous example, you created the filter function to migrate all rows older than 1 June 2016. Assume that you want to send all rows older than 1 month to the cloud. Since the function must be deterministic and you cannot alter the existing one because it is defined with SCHEMABINDING attribute, you need to create a new function with the literal date again. For instance, on 1 August, you would need a function that instructs the system to migrate rows older than 1 July:

CREATE FUNCTION dbo.StretchFilter20180301(@col DATETIME)   
RETURNS TABLE   
WITH SCHEMABINDING    
AS    
       RETURN SELECT 1 AS is_eligible  
WHERE @col < CONVERT(DATETIME, '01.03.2018', 104);

Now you can assign the newly created function to the T1 table:

ALTER TABLE dbo.T1    
SET (REMOTE_DATA_ARCHIVE = ON    
    (FILTER_PREDICATE = dbo.StretchFilter20180301(c2), MIGRATION_STATE = OUTBOUND ) );

Finally, you should remove the old filter function:

DROP FUNCTION IF EXISTS dbo.StretchFilter; 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.239.214