Could someone solve this please:
CREATE TRIGGER tr_admin_ForInsert
ON admin
FOR INSERT
AS
BEGIN
DECLARE adminID INT
SELECT adminID = adminID from inserted
insert into adminAudit
Values ('New Admin with ID = ' + Cast (ID as NVARCHAR(5)) + ' is added at ' + cast(Getdate() as NVARCHAR (20)))
END
I get the error message:
Msg 155, Level 15, State 2, Procedure tr_admin_ForInsert, Line 7
'INT' is not a recognized CURSOR option.
INTis underlined and says '"is not a recognized CURSOR option'SELECTis underlined and says 'Incorrect syntax near 'SELECT'. Expecting CURSOR, or ID
This is my inserted table for admin:
USE [zachtravelagency]
CREATE TABLE admin
(
[adminID] INTEGER NOT NULL IDENTITY (1,1) PRIMARY KEY,
[firstname] NVARCHAR(30) NOT NULL,
[surname] NVARCHAR(50) NOT NULL,
[username] NVARCHAR(30) NOT NULL,
[password] NVARCHAR(30) NOT NULL,
);
This is my inserted table for adminAudit:
CREATE table adminAudit
(
[adminAuditID] INTEGER NOT NULL IDENTITY (1,1) PRIMARY KEY,
[AuditData] NVARCHAR(200) NOT NULL
)
Thanks.
@symbol, i.e.DECLARE adminID INTshould beDECLARE @adminID INTSELECT @adminID = adminID from insertedis doomed to fail as the statement might return more than one record.