ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
CREATE TABLE [dbo].[HPMS_CompetencyTypes](CompetencyType 
varchar(50) )

go
create trigger hpms_create_Insert
on HPMS_CompetencyTypes
for insert 
as
if Exists ( select * from [HPMS_CompetencyTypes] where 
CompetencyType=(select * from [HPMS_CompetencyTypes]))
begin 
Rollback tran
Raiserror ('duplicate value',12,6)
go 
insert HPMS_CompetencyTypes (CompetencyType) values ('new')
 

I'm new to trigger can any one tell me where is the issue. 
Please.
 Question Submitted By :: Indira
I also faced this Question!!     Rank Answer Posted By  
 
  Re: CREATE TABLE [dbo].[HPMS_CompetencyTypes](CompetencyType varchar(50) ) go create trigger hpms_create_Insert on HPMS_CompetencyTypes for insert as if Exists ( select * from [HPMS_CompetencyTypes] where CompetencyType=(select * from [HPMS_CompetencyTypes])) begin Rollback tran Raiserror ('duplicate value',12,6) go insert HPMS_CompetencyTypes (CompetencyType) values ('new') I'm new to trigger can any one tell me where is the issue. Please.
Answer
# 1
pls try this now,

CREATE TABLE [dbo].[HPMS_CompetencyTypes](CompetencyType 
varchar(50) )
 go 

create trigger hpms_create_Insert on HPMS_CompetencyTypes 
for insert as 
if Exists ( select * from [HPMS_CompetencyTypes] where 
CompetencyType=(select * from [HPMS_CompetencyTypes]))
 begin 
 Rollback tran
Raiserror ('duplicate value',12,6) 
End
  go
insert HPMS_CompetencyTypes (CompetencyType) values ('new')
 
Is This Answer Correct ?    1 Yes 0 No
Mano Karnan
 
  Re: CREATE TABLE [dbo].[HPMS_CompetencyTypes](CompetencyType varchar(50) ) go create trigger hpms_create_Insert on HPMS_CompetencyTypes for insert as if Exists ( select * from [HPMS_CompetencyTypes] where CompetencyType=(select * from [HPMS_CompetencyTypes])) begin Rollback tran Raiserror ('duplicate value',12,6) go insert HPMS_CompetencyTypes (CompetencyType) values ('new') I'm new to trigger can any one tell me where is the issue. Please.
Answer
# 2
CREATE TABLE [dbo].[HPMS_CompetencyTypes](CompetencyType 
varchar(50) )
 go 
alter trigger hpms_create_Insert on HPMS_CompetencyTypes
 for insert 
as 
begin try
if Exists ( select * from [HPMS_CompetencyTypes]  
where CompetencyType=(select CompetencyType from inserted)) 
begin 
 select * from [HPMS_CompetencyTypes]
end
end try
begin catch
Rollback tran 
Raiserror ('duplicate value',12,6) 
end catch

go 
insert HPMS_CompetencyTypes (CompetencyType) values ('new')
 
Is This Answer Correct ?    0 Yes 0 No
Durga Prasad
 
 
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
what is the out put of below queries? a. select * from Emp where null = null; b. select * from Emp where 1=1; Patni9
What is normalization in Database ?  4
What is database normalization? Digicel5
event classes in sql server Accenture1
CLR Integration ? what is Notification services ? Satyam1
About types of indexes in SQL server ? Cognizent1
What is a Trace frag?Where can we use this?  1
What are sub-queries? Give example? In which case sub-queries are not feasible? Infosys3
How do SQL server 2000 and XML linked?  2
Can we create clustered index on non primary key column CTS14
i have a table #temp1(id, Name groupname ) and record like this 1 R1 S 2 R3 S 3 R2 S 4 R4 D 5 R5 D 6 R6 K 7 R7 K 8 R8 L 9 R9 L 10 R10 L 11 R11 K and i want to display record based on user defind sorting order e.g. 1 R4 D 2 R5 D 3 R6 K 4 R7 K 5 R11 K 6 R1 S 7 R3 S 8 R2 S 9 R8 L 10 R9 L 11 R10 L  4
Write a query to delete duplicate records in SQL SERVER Infosys19
What is the difference between DTS and SSIS? Allianz3
What do you mean by COLLATION?  4
How to write a script for upate the data in prod , i have 50000 row are there TCS2
What is the use of placing primary key and foreign key constrains on columns. Value-Labs2
how to dispaly a particular row details from a given table  1
Is it possible to have more then one foreign key in a single table? if possible, is this the good way to design the table?  2
how to know Who Is Blocking Your SQL Server?  3
How can you see what type of locks used?  1
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com