help with a instead of trigger

  • Jeff all valid points. The ssn right now is last four and the plan is to go to a hashed number right now the table is in the proof of concept stage.

  • gfoulks (3/13/2014)


    Jeff all valid points. The ssn right now is last four and the plan is to go to a hashed number right now the table is in the proof of concept stage.

    Thanks for the feedback on the encryption thing.

    Shifting gears back to your problem, I still think the staging table concept I spoke of might work better for you in the long run.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • gfoulks (3/13/2014)


    It sort of makes sense but not entirely. I'm not evaluating the phone numbers together but instead want to treat them two separate values

    Does the ANI = "6141112222' or does the ANI = '6141113333' if so then discard that record.

    To me the OR condition seemed like the correct choice because I am evaluating multiple conditions for the same column. The AND would seem to be more appropriate if I were evaluating two or more columns (column a = 'x' and column b = 'y').

    Your logic said

    ANI <> '6141112222'

    or

    ANI <> '6141113333'

    This means that any value is acceptable because if EITHER of those conditions is true the whole expression is true.

    So let's walk through this. For our example let's say that the value of ANI is 6141113333.

    I will use the actual value to demonstrate this instead of the column name.

    Where '6141113333' <> '6141112222'

    OR

    '6141113333' <> '6141113333'

    Do you know see why this doesn't work? The first conditional check will evaluate to true because those two values are not equal. Because your logical operator is OR only 1 of the two conditions must evaluate to true. You need both of them to evaluate to true. Does that help your understanding?

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

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

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