Computed Column Divide by Zero?

  • Hugo Kornelis (10/15/2010)


    tilew-948340 (10/15/2010)


    Hi Hugo.

    The first time I tried the PERSISTED, I got the divide by zero error AFTER the "show table" wich does not seem to be, as I understand it, what it should be doing. So I tried many "set" option, wich brought me to the "declare" error...

    So, if I put the PERSISTED word, should not the error happend after the "Insert null"?

    Here is the code that I used - if you compare this to the QotD, you'll see that adding PERSISTED at one place is the only modification.

    ...

    If I run this (from SSMS, against SQL Server 2005), I get an error after "Insert Zeroes", and a result set with two rows (one with values; one with NULLs)

    ah! HA! I knew I was doing someting wrong. I was putting the "PERSISTED" after the "QTot AS QF1 + QF2", wich mean nothing for a division by zero. Now, I do understand what "persisted" do!

    Thank you very much!

  • Thanks for the question.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Good question, i thought it would happen upon insert, but I didn't realize that it was not persisted.

    /Håkan Winther
    MCITP:Database Developer 2008
    MCTS: SQL Server 2008, Implementation and Maintenance
    MCSE: Data Platform

Viewing 3 posts - 31 through 33 (of 33 total)

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