• Lynn Pettis (9/2/2014)


    Welsh Corgi (9/2/2014)


    Ed Wagner (9/2/2014)


    Good. Now all you have to do is look at the format mask of your TO_DATE function.

    TO_DATE(''2014-09-02'',''YYYY.MM.DD'')

    The date string doesn't match the format string.

    Thanks.

    I need TO_DATE(@CurrentDate,''YYYY.MM.DD'') to use a variable as opposed to a hard coded value.

    I'm having trouble with the syntax.

    So this (what I had posted further up above doesn't help? If not why not?

    declare

    @SQLCmd nvarchar(max),

    @MyDate DATE;

    set @MyDate = '20140808';

    select @SQLCmd = N'

    SELECT

    CAST(CAE_RDB_ENTRY_DATE as Date),

    *

    FROM OPENQUERY(LS_RDB_DWH, ''

    SELECT

    *

    FROM

    RDB_DWH_ASSOCIATE_ENTITY

    WHERE

    CAE_RDB_ENTRY_DATE > = TO_DATE(''''' + REPLACE(CONVERT(nvarchar(10), @MyDate, 111),'/','.') + ''''',''''YYYY.MM.DD'''') ORDER BY 1''

    )';

    print @SQLCmd;

    --exec sp_executesql @SQLCmd;

    SELECT

    CAST(CAE_RDB_ENTRY_DATE as Date),

    *

    FROM OPENQUERY(LS_RDB_DWH_POLICY52, '

    SELECT

    *

    FROM

    RDB_DWH_ASSOCIATE_ENTITY

    WHERE

    CAE_RDB_ENTRY_DATE > = TO_DATE(''2014.01.05'',''YYYY.MM.DD'') ORDER BY 1'

    )

    OLE DB provider "MSDASQL" for linked server "LS_RDB_DWH_POLICY52" returned message "[Oracle][ODBC][Ora]ORA-00942: table or view does not exist

    ".

    Msg 7350, Level 16, State 2, Line 2

    Cannot get the column information from OLE DB provider "MSDASQL" for linked server "LS_RDB_DWH_POLICY52".

    @CurentDate is in format 'YYYY-MM_DD'

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/