Default Values

  • Hello all,

    I am trying to provide "default constraints" for one of my tables.

    I don't want to use a built in DEFAULT constraint on the field because I only want to set it for the records with a certain value in the Status column. Records without this value should remain NULL.

    I wrote a DML AFTER INSERT trigger that changes the inserted value to the appropriate default value but I am concerned with how this will affect performance. This is a pretty busy OLTP server and since the trigger will be firing with every insert I fear that it will slow the system down.

    How badly do you think this could affect performance? Is there an alternative to this that would perform better?

    Thank you in advance for your input.

  • I'd just make it the default value in the stored procedure that inserts the data in the first place, assuming you're using procs.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Wow...why didn't I think of that. Good stuff. Thanks, GSquared!

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

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