May 3, 2012 at 10:16 am
I have been asked in an interview.. why should we go for trigger when we can achieve the same by the normal coding itself??...
and whats the main purpose of view other than security reason while the same query can be used????
Kindly advice me on this....
May 3, 2012 at 10:40 am
Personally I prefer to avoid the use of triggers wherever possible. The can have adverse side effects and cause performance and concurrency issues.
Having said that, they can typically be added to accomplish something after a design has been put into place without changing any existing code.
Views allow for changes of the underlying table structure (schema) while still maintaining the interface to any clients or procedures that are already in place.
The probability of survival is inversely proportional to the angle of arrival.
May 3, 2012 at 11:16 am
Thanks a lot !!!!
May 3, 2012 at 11:26 am
The correct response in an interview, if you don't know the answer to a question, is "I don't know. I'd have to research that. Should be easy enough to Google it." or something to that effect.
That having been said, there are advantages to using triggers for things like complex referential integrity, audit trails, logging, DML on complex views, and several other areas of SQL Server that are best served by code at that scope. There are drawbacks to them as well, which outweigh the advantages in most cases. But you need to know both in order to make the proper decision in any given case.
Views vis-a-vis security is a very limited use of them, and generally a last-ditch security effort when you don't know what you're doing at other levels of the security paradigm.
- 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
May 3, 2012 at 11:30 am
Instead of writing the code at every Insert, Update or Delete Sql provides an automatic functionality triggers which gets called automatically when any of these three operations performed.
Views are also, instead of writing the big code for selecting from multiple table every time, u can directly call that view.
May 3, 2012 at 12:10 pm
How is a view used like a trigger?
May 3, 2012 at 12:54 pm
kiro72 (5/3/2012)
How is a view used like a trigger?
They aren't.
- 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
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply