开发者

Creating a simple SQL trigger

I have a table called Events that I want to insert information to.

Here is the Event table schema:

create table Evento
(
    ID int primary key identity(1,1),
    Fecha datetime not null,
    Descripcion nvarchar(256) not null,
    Aplicacion nvarchar(256) not null,
    Equipo nvarchar(256) not null,
    Usuario nvarchar(256) not null,
    Tabla nvarchar(256) not null,
    Tipo nvarchar(256) not null
)

Now here is the trigger script I'm trying to create whenever a new record is inserted into the Compra (Purchase) table:

create trigger AuditoriaCompraInsert on Compra for INSERT
as
insert into Evento select GETDATE(), CONVERT(varchar(128),i.ID), APP_NAME, 
HOST_NAME, SYSTEM_USER, 'Compra', 'Insert' from inserted i

I get these errors:

Msg 207, Level 16, State 1, Procedure AuditoriaCompraInsert, Line 3 Invalid开发者_如何学JAVA column name 'APP_NAME'. Msg 207, Level 16, State 1, Procedure AuditoriaCompraInsert, Line 4 Invalid column name 'HOST_NAME'.

Any guidance?


HOST_NAME(), etc are functions. Add the parenthesis.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜