narasiman rao

narasiman rao

  • NA
  • 519
  • 768.6k

when i am creating a trigger shows error

Mar 19 2017 2:39 AM
  The above one is doing in sql server 2008


tblemployeedetailsas follows

id int
Name Varchar(50)
Salary Varchar(50)
Gender Varchar(50)
Deptid int


Tblaudit as follows

id int
Auditdata varchar(50)


i am creating a trigger whenever record inserted in the tblemployeedetails, in tblaudit record will be inserted. for that i am creating a trigger as follows.


create triggger tbl_insert_foremployee
on tblemployeedetails
for insert
AS

BEGIN
declare @id int
select @id = id from inserted
insert into Tblauditdata
values ('New employee with id = ' + cast(@id as varchar(5)) +
'is added at ' + cast(Getdate() as nvarchar(20)))
END
GO


when i execute the above trigger shows error as follows

Unknown object type 'triggger' used in a CREATE, DROP, or ALTER statement.

please help me what is the mistake i made. 

Answers (3)