Reputation: 8695
I'm just learning the basics of how triggers work/what the best uses for them are and I found a tutorial online just to get the look and feel of them. The below trigger doesn't run and the error given is incorrect syntax was encountered while parsing go
set nocount on
create table source1(sou_id int identity, sou_desc varchar(10))
go
create trigger tr_source1_insert
on source1
for insert as print getdate()
go insert source1 (sou_desc) values ('test 1')
can someone explain what's going on here, and what i should've expected to see?
edit: little things were fixed, still seeing the same error
Upvotes: 0
Views: 796
Reputation: 1196
Try this
set nocount on
create table source1(sou_id int identity, sou_desc varchar(10))
go
create trigger tr_source1_insert
on source1
for insert as
print getdate()
go
insert source1 values ('test 1')
'Go' statement needs to be on a separate line.
Upvotes: 1