Click here to Skip to main content
15,914,066 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I Created a delete Trigger.And When I Trying to delete A column in Table.It Shows the Error.


Code:
SQL
Create TRIGGER TRIGGERDELETE
   ON   Employee
   AFTER DELETE
AS 
BEGIN
	Declare @id as int
	Declare @Name as nvarchar(10)
	select @id=EmployeeId,@Name=FirstName from deleted
	Insert Into EmployeeAUDIT1(Description) 
	Values
	('A Employee With Name '+ @Name  + 'Id ' +CAST( @id as nvarchar)+ ' is deleted on '+ CAST(GETDATE() as nvarchar(10)))

END
GO



Error:
Msg 8152, Level 16, State 10, Procedure TRIGGERDELETE, Line 9
String or binary data would be truncated.
The statement has been terminated.
Posted
Updated 1-Jul-15 19:50pm
v3

Hello ,
This type of error comes when The field is NOT big enough to hold the data that you want to insert in table . First check the table structure and then insert .
 
Share this answer
 
Comments
Member 11804811 6-Jul-15 10:08am    
Thanks...The Error removed
Increase The Size Of Description Column Of EmployeeAUDIT1 Table.
 
Share this answer
 
Comments
Member 11804811 6-Jul-15 10:08am    
Thanks....
To be precise you need to increase size of Description field of EmployeeEdit1 table. Try alter it as below

SQL
ALTER TABLE EmployeeEdit1 ALTER COlUMN DESCRIPTION NVARCHAR(1024)
 
Share this answer
 
Comments
Member 11804811 6-Jul-15 10:07am    
Thanksss

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900