Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

INSERT EVENT TRIGGER

$
0
0

Hi All,

I am trying to INSERT INTO base table so that my trigger returns the expected output. But when I do that I get error-

Msg 8152, Level 16, State 13, Procedure tr_tblemployee_ForInsert, Line 10
String or binary data would be truncated.
The statement has been terminated.

I am using:

CREATE TRIGGER tr_tblemployee_ForInsert
on tblemployee
FOR INSERT
AS
BEGIN
    DECLARE @EmployeeID Int
    SELECT @EmployeeID = EmployeeID FROM INSERTED

INSERT INTO tblEmployAudit VALUES (
 'New Employee with ID =' +
   CAST(@EMPLOYEEID as NVARCHAR(20)) +
 'added at' +
   CAST(GETDATE() as NVARCHAR(20))
)
END

The tblemployee table has EmployeeID as INT type and the tblEmployAudit  table has EmployeeID as Primary key INT type.

Please advise.

Best R.

Sk


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>