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 why variables called the most powerful component of ssis?

994


Can we deploy SSRS reports on our personal website?

162


Can sql server be linked with other servers like oracle?

905


What are the recovery models in sql server 2000?

927


How to find the source of a table in sql server?

925


What is default constraint in ms sql server?

968


How to use union to merge outputs from two queries together in ms sql server?

1011


What are the advantages of using third-party tools?

921


What is a bit datatype?

927


What is parameterized reports in ssrs ?

141


What is the order by used for?

965


Can we write a distributed query and get some data which is located on other server and oracle database?

1178


How will you know when statistics on a table are obsolete?

1034


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

1067


what are the steps you will take, if you are tasked with securing an sql server? : Sql server database administration

957