Which is better in performance - CONSTRAINT or TRIGGER over
a column which restricts say an input of particular value
in a column of a table?

Answers were Sorted based on User's Feedback



Which is better in performance - CONSTRAINT or TRIGGER over a column which restricts say an input ..

Answer / jerry joseph

Restricting the input using CONSTRAINT will have better
performance but there is a limit to the types of constraints
which we can provide..

With TRIGGERS you have more flexibility and provide a more
variety restrictions to the input.. for example you can
prevent a normal delete and make it a soft delete by setting
an IsDeleted flag using trigger.. we cant have that kind of
flexibility using Constraints..

Is This Answer Correct ?    6 Yes 1 No

Which is better in performance - CONSTRAINT or TRIGGER over a column which restricts say an input ..

Answer / monal

Constraints gets evaluated before statement can be either
inserted or deleted or updated. While trigger executes
after or at the same time statement is executing. So if you
have to roll back transactio because transaction not
meeting condition there is no overhead when you are using
constraint ,but if you have to roll back transaction and
you have a trigger on that table or column either 1
transaction goes through before rolling back. So basically
trigger consumes more resources.

Is This Answer Correct ?    7 Yes 3 No

Which is better in performance - CONSTRAINT or TRIGGER over a column which restricts say an input ..

Answer / guest

Constraint is better in terms of performance for same
operation. Why??

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More SQL Server Interview Questions

Explain what are the restrictions that views have to follow? : SQL Server Architecture

0 Answers  


What do you mean by SQL injection attack?

0 Answers   Ittiam Systems,


How will you make an attribute not process? : sql server analysis services, ssas

0 Answers  


What is the maximum number of instances in 32 bit and 64 bit sql server 2012?

0 Answers  


how do you test proper tcp/ip configuration windows machine? : Sql server database administration

0 Answers  






What is b tree index?

0 Answers  


What is a materialized view?

3 Answers  


How many index can be created for single table

4 Answers   CarrizalSoft Technologies, Verizon,


whats the maximum size of view state??

0 Answers  


What are the options which must be set to allow the usage of optimistic models?

0 Answers  


What is service broker? : sql server database administration

0 Answers  


What are the new features in SQL Server 2005 when compared to SQL Server 2000?

0 Answers  


Categories