Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 Posted / durga prasad

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are acid properties of transaction?

945


Explain about merge replications?

1009


What are the advantages of log shipping?

988


How to assign null values to variables or columns?

967


How can I know what locks are running on which resource?

947


How to name query output columns in ms sql server?

958


What is importing utility?

978


Can you use order by when defining a view?

968


How do I install only the client tools of sql server 2000?

1061


Explain what are the basic functions for master, msdb, model, tempdb databases?

965


What is explicit mode in sql server?

1053


Explain sql server service broker?

968


What is the difference RDBMS and Graph Database?

1042


what are statistics, under what circumstances they go out of date, how do you update them? : Sql server database administration

942


What is data set in report?

135