Trigger Question

  • Hello,

    I have written a trigger to update a certain field, the trigger is working properly.

    I explain what I'm trying to do.

    I have a certain field in a certain table.

    I compare certain values in that table with another table and I take the value from another table.

    This all works fine

    But when the value is NULL in the other table he always returns null, what is normal.

    But when the value is null the user would like to put a value in that table himself, but then always the trigger fires and return value NULL

    Is there any possibility to solve that so It is also getting possible for the user to change the value for a certain field without the trigger fires.

    Thx

    ken

  • For the Null values try to use ISNULL if you can do something so for better solution read my sig !

    more info here: http://msdn.microsoft.com/en-us/library/ms184325.aspx

    ============================================================
    SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
    http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]

  • Dugi's got you on the right track. use ISNULL to put in a default value, or raise an error before it gets to the trigger in the first place.

    as an FYI, no trigger/storedproc/function can raise any MsgBoxes/inpout boxes for user input; even if it did, the inputbox would open on the sERVER where the code gets executed, not at the client statiuon, right?

    you'd need to get your user interface to check the values before they get passed to the server.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 3 posts - 1 through 3 (of 3 total)

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