rewrite code to eliminate isnull

  • You cannot include GETDATE() inside a UDF, you can however make an input parameter to accept it. It comes from the hole deterministic/non-deterministic rules.

  • To add to Antares, here's an example what can happen, when you choose to workaround this GETDATE() - UDF issue with a view, which is sometimes suggested.

    http://www.insidesql.de/content/view/100/

    It's in German, however the code speaks for itself.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Nullable columns do cause the query analyzer to double pass - once for nulls and once for non-null.
    May I suggest creating a view of your data to handle the nulls, then select from the view.
     
    CREATE VIEW tableA_vw AS
    SELECT ISNULL(datecol,getdate()),
    .
    .
    .
    FROM TableA

    Select col_a from some_table

    where Date_col = (select date from tableA_vw where id=host_id())

     

Viewing 3 posts - 16 through 17 (of 17 total)

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