Tuesday, February 14, 2012

Constraints and Triggers

We have a database that is using triggers to support referntial integrity.
Is it possible to use constraints on new tables and slowly replace triggers
with constraints in the future?
DavidYes you can migrate to foreign key constraints instead of using triggers.
This is the preferred method and can improve performance as well.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"David C" <dlchase@.lifetimeinc.com> wrote in message
news:u1uday5MFHA.1308@.TK2MSFTNGP15.phx.gbl...
> We have a database that is using triggers to support referntial integrity.
> Is it possible to use constraints on new tables and slowly replace
> triggers with constraints in the future?
> David
>|||Yes, it is much better to use FK instead of triggers
Look at cascade on delete,cascade on update in the BOL.
"David C" <dlchase@.lifetimeinc.com> wrote in message
news:u1uday5MFHA.1308@.TK2MSFTNGP15.phx.gbl...
> We have a database that is using triggers to support referntial integrity.
> Is it possible to use constraints on new tables and slowly replace
triggers
> with constraints in the future?
> David
>|||David,
Sure, and this is what Microsoft recommend, to enforce RI using DRI.
AMB
"David C" wrote:
> We have a database that is using triggers to support referntial integrity.
> Is it possible to use constraints on new tables and slowly replace triggers
> with constraints in the future?
> David
>
>

No comments:

Post a Comment