Select chapter



Basics (2.papers)
Data Types (2.papers)
Table-designing (1.papers)
Queries-Commands (3.papers)
String functions (2.papers)
Subqueries (1.papers)
Joins (1.papers)
Constraints (1.papers)
Triggers (1.papers)
Hide

Sponsored Links


  

sql triggers interview questions and answers

Please read the below given table for solving questions from 1 to 13
eidfnamelnameagesalarydeptdoj
1rajeevsukla2312000.net23-Oct-11 12:00:00 AM
2sowmyakumari2319000db13-Nov-10 12:00:00 AM
3kishorekumar2736000android16-Oct-11 12:00:00 AM
4abimanyubiswal22nullandroid25-May-10 12:00:00 AM
5sonikumar2421800.net21-Jun-09 12:00:00 AM
6anu_singh2212000db23-Oct-10 12:00:00 AM
7_dineshmoh%anty2315000.net26-Aug-09 12:00:00 AM
8nischala_kumari2218000db19-Jul-08 12:00:00 AM
9gouravchourasia2420000android06-Oct-13 12:00:00 AM
Note: Assume table is present in a database named skillgun , the Schema name is dbo and the table name as Employees ;
1
What is a trigger in SQL Server?
  1. A trigger in SQL Server is a piece of code which will be executed automatically for DML or DDL operation for which trigger is created.
  2. A trigger is a type of function which must be called explicitly for executing business logic (for executing set of T-SQL statements)
  3. A trigger is a transaction created for checking T-SQL statements execution results.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
2
Which of the following types of Triggers are supported in SQL Server?
  1. for trigger
  2. after trigger
  3. instead of trigger
  4. All the above.
Show Answer
Share Facebook gmail Twitter
3
Which of the following trigger will be executed before performing insert operation on employees table ?
  1. create trigger trg_ins_Employees1
    on employees
    after insert
    as
    /*set of t-sql statements */
  2. create trigger trg_ins_Employees2
    on employees
    instead of insert
    as
    /*set of t-sql statements */
  3. Both the options are correct.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
4
Which of the following trigger will be executed after update operation on employees table?
  1. create trigger trg_ins_Employees1
    on employees
    after update
    as
    /*set of t-sql statements */
  2. create trigger trg_ins_Employees2
    on employees
    instead of update
    as
    /*set of t-sql statements */
  3. Both the options are correct.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
5
What is the difference between after trigger and instead of trigger?
  1. after trigger executes before constraint checking and instead of trigger executes after constraint checking.
  2. Instead of triggers will be executed before executing the actual query. After trigger will be executed after executing the actual query.
  3. Both the options are correct.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
6
What is the use of inserted table?
  1. An inserted table is created automatically when user performs any dml operation on any table.
  2. An inserted table is created with the same structure as the table on which an insert or update operation is performed.
  3. An inserted table is created in the current data base when user is performing any insert operation(not for update or delete operation).
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
7
What is the use of deleted table?
  1. deleted table is created automatically when user performs any dml operation on any table.
  2. deleted table is created with the same structure as the table on which delete or update operation is performed.
  3. deleted table is always created in the current data base when user is performing delete operation.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
8
Which of the following trigger will not allow user to delete least paid employee?
  1. create trigger trgDel
    on employees
    instead of delete
    as
     declare @minsal int ;
     select @minsal=MIN(salary) from employees ;
     declare @crntsal int;
     select @crntsal=salary from deleted ;
     if(@crntsal=@minsal)
     begin
       print 'transaction cancelled ';
       rollback transaction ;
     end
  2. create trigger trgDel
    on employees
    instead of delete
    as
     declare @minsal int ;
     select @minsal=MIN(salary) from employees ;
     declare @crntsal int;
     select @crntsal=salary from deleted ;
     if(@crntsal=@minsal)
     begin
       print 'transaction cancelled ';
     end
  3. None of the above .
Show Answer
Share Facebook gmail Twitter
9
Which of the following trigger will not allow user to update highest paid employees salary?
  1. create trigger trgUpd
    on employees
    instead of update
    as
     declare @maxsal int ;
     select @maxsal=MAX(salary) from employees ;
     declare @crntsal int;
     select @crntsal=salary from inserted ;
     if(@crntsal=@maxsal)
     begin
       print 'transaction cancelled ';
     end
  2. create trigger trgUpd
    on employees
    instead of update
    as
     declare @maxsal int ;
     select @maxsal=MAX(salary) from employees ;
     declare @crntsal int;
     select @crntsal=salary from inserted ;
     if(@crntsal=@maxsal)
     begin
       print 'transaction cancelled ';
       rollback transaction ;
     end
  3. None of the above .
Show Answer
Share Facebook gmail Twitter
10
Which of the following table is/are created during update operation ?
  1. inserted.
  2. updated.
  3. deleted.
  4. inserted and deleted.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
12
How to delete a trigger?
  1. delete trigger <trigger-name>
  2. drop trigger <trigger-name>
  3. truncate trigger <trigger-name>
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :