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

What is the difference between DATETIME2 and DATETIME?

1 Answers   Infosys,


what is normalization? what is denormalization?

9 Answers   Satyam,


What are the difference between data mart and data warehouse? : sql server analysis services, ssas

1 Answers  


When do u use clustered index and non-clustered index?

3 Answers   IBM,


How to drop existing indexes in ms sql server?

1 Answers  


How to configure and test odbc dsn settings?

1 Answers  


Tell me what do you understand by a view? What does the with check option clause for a view do?

1 Answers  


What will be query used to get the list of triggers in a database?

1 Answers  


Explain Different types of Projects?

1 Answers  


What stored by the model? : sql server database administration

1 Answers  


Explain collation?

1 Answers  


What is the difference between executequery () and executeupdate ()?

1 Answers  


Categories