What is the reason of the difference in treatment of user-defined function call statement on different servers?

  • Hi folks!

    There is a issue I can't take the reason of.

    Some table-function is called in the following manner:

    SELECT

    ...

    FROM Table B

    LEFT JOIN dbo.udf_fm_DataList(DATEADD(DAY, -1, @Date), @ID) A ON A.ID = B.ID

    This code is treated by the one server but isn't treated by the other one. The following message is appeared when the error occurs:

    Incorrect syntax near 'DATEADD'.

    I had to modify the code: add new variable @DateMinus1Day and replace DATEADD(DAY, -1, @Date) with the one.

    DECLARE @DateMinus1Day DATETIME

    SET @DateMinus1Day = DATEADD(DAY, -1, @Date)

    SELECT

    ...

    FROM Table B

    LEFT JOIN dbo.udf_fm_DataList(@DateMinus1Day, @ID) A ON A.ID = B.ID

    I wonder what could be cause of such different treatment?

  • Need more information. What versions of SQL Server are being run on the two servers and what is the database compatibility modes on the databases in question?

  • Lynn Pettis (5/18/2009)


    Need more information. What versions of SQL Server are being run on the two servers and what is the database compatibility modes on the databases in question?

    Both servers are SQL Server 2005 with Compatibility Level = 90.

    I still can't take in why there is a difference... =|

  • The guy who is responsible for the second server gave me wrong info =) Actually compatibility level was 80. So, your question, Lynn Pettis, included the clue for the answer! Cheers! =)

  • Glad you resolved the problem I am.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply