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
What is the difference between sdf and mdf?
What is sql injection? How to protect against sql injection attack?
How to create view in stored procedure sql server?
You want to use a perspective in an mdx query. How do you select the perspective?
What is 4nf in normalization form?
What are the purpose of Normalisation?
What is it’s similarity with sql server?
Tell me the use of keyword with encryption. Create a store procedure with encryption?
How to replace given values with null using nullif()?
How to use the inserted and deleted pseudo tables?
What is the security principal at the server level that represents your session?
how to do partition in sqlserver
What are the dmvs?
What are the differences between web role and worker role?
What is Extended user-defined?