I am getting the below error while executing a stored procedure
USE [Smart2uat] GO /****** Object: StoredProcedure [dbo].[SPJOB_ALLLOC] Script Date: 2/11/2016 12:37:40 PM ******/ SET ANSI_NULLS OFF GO SET QUOTED_IDENTIFIER OFF GO ALTER PROCEDURE [dbo].[SPJOB_ALLLOC] AS declare @cardno as varchar(8) declare @iodate as datetime declare @iotime as varchar(8) declare @holdername as varchar(100) declare @IO_MSKID as varchar(7) declare @IO_LOCATION_CODE as varchar(3) declare @IO_COMPANY_CODE as varchar(3) declare @IO_ACTIVITY_CODE as varchar(6) declare @IO_FIRST_NAME as varchar(20) declare @IO_THIRD_NAME as varchar(20) declare @IO_EMPLOYEE_CODE as varchar(3) declare @rows as integer declare curatt1 cursor for select iodate,cardno,iotime,holdername from iodatatmp where isnull(cardno,'')<>'' and isnull(cardno,'') not like 'XXXX%' order by iotime open curatt1 fetch next from curatt1 into @iodate,@cardno,@iotime,@holdername WHILE @@FETCH_STATUS = 0 BEGIN if not exists(select CardNo from iodata where iodate= @iodate and cardno= @cardno) begin select @IO_MSKID = '' select @IO_MSKID=MSKID,@IO_LOCATION_CODE=LOCATION_CODE,@IO_COMPANY_CODE=COMPANY_CODE,@IO_ACTIVITY_CODE=ACTIVITY_CODE,@IO_FIRST_NAME=FIRST_NAME,@IO_THIRD_NAME=THIRD_NAME,@IO_EMPLOYEE_CODE=EMPLOYEE_CODE from Employee_Mast where card_number = @cardno IF @IO_MSKID <> '' insert into iodata(cardno,iodate,iotime,holdername,IO_MSKID,IO_LOCATION_CODE,IO_COMPANY_CODE,IO_ACTIVITY_CODE,IO_FIRST_NAME,IO_THIRD_NAME,IO_EMPLOYEE_CODE) values(@cardno,@iodate,@iotime,@holdername,@IO_MSKID,@IO_LOCATION_CODE,@IO_COMPANY_CODE,@IO_ACTIVITY_CODE,@IO_FIRST_NAME,@IO_THIRD_NAME,@IO_EMPLOYEE_CODE) end fetch next from curatt1 into @iodate,@cardno,@iotime,@holdername END close curatt1 deallocate curatt1 delete from iodata where cardno like 'XXXX%' error is
Msg 8152, Level 16, State 14, Procedure SPJOB_ALLLOC, Line 31 String or binary data would be truncated. The statement has been terminated. (0 row(s) affected) Can you please help me..? I am attaching the table design of iodatatmp on which the cursor is fetching and the destination table - Iodata
I have checked the length of the variable...and seems everything fine....Kindly help me..Thanks in advance


WHILE @@FETCH_STATUS = 0I've checked@iodate,@cardno,@iotime,@holdernamematching with source and destination tables. Still getting error