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

Explain what is row_number function?

1035


What are basics of policy management?

1102


What is a unique index?

932


How will you optimize a stored procedure optimization?

1040


Can you get second highest salary from the table?

965


How you can get a list of all the table constraints in a database?

956


What is the use of partition by in sql server?

933


Explain full-text indexing?

980


How does a profiler work?

929


what is a schema in sql server 2005? Explain how to create a new schema in a database? : Sql server database administration

1034


what are user defined datatypes and when you should go for them? : Sql server database administration

1018


How do I setup a local sql server database?

1006


Tell me what is de-normalization and what are some of the examples of it?

1043


Tell me what is difference between clustered and non clustered index?

944


How to execute stored procedure in select statement sql server?

1061