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 why variables called the most powerful component of ssis?
Can we deploy SSRS reports on our personal website?
Can sql server be linked with other servers like oracle?
What are the recovery models in sql server 2000?
How to find the source of a table in sql server?
What is default constraint in ms sql server?
How to use union to merge outputs from two queries together in ms sql server?
What are the advantages of using third-party tools?
What is a bit datatype?
What is parameterized reports in ssrs ?
What is the order by used for?
Can we write a distributed query and get some data which is located on other server and oracle database?
How will you know when statistics on a table are obsolete?
I have all the primary data files, secondary data files as well as logs. Now, tell me can I still restore the database without having a full backup? : sql server database administration
what are the steps you will take, if you are tasked with securing an sql server? : Sql server database administration