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
How can change procedure in sql server?
What is a fill factor?
what is the difference between openrowset and openquery?
Is profiler the only tool that has the ability to audit and identify ddl events? : sql server security
difference between Clustered index and non clustered index ?
What does set rowcount do?
How to transfer an existing table from one schema to another schema in ms sql server?
What is the contrast between sql and mysql?
Explain features and concepts of analysis services?
What is the difference between osql and query analyzer?
When would you use a before or after trigger?
How to rename an existing column with sql server management studio?
What is acid mean in sql server?
Do you know what is sql injection?
How retrieve field names from the table in SQL through JAVA code?