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
Explain what is row_number function?
What are basics of policy management?
What is a unique index?
How will you optimize a stored procedure optimization?
Can you get second highest salary from the table?
How you can get a list of all the table constraints in a database?
What is the use of partition by in sql server?
Explain full-text indexing?
How does a profiler work?
what is a schema in sql server 2005? Explain how to create a new schema in a database? : Sql server database administration
what are user defined datatypes and when you should go for them? : Sql server database administration
How do I setup a local sql server database?
Tell me what is de-normalization and what are some of the examples of it?
Tell me what is difference between clustered and non clustered index?
How to execute stored procedure in select statement sql server?