Hi,
The following code throws "Int" to "numeric" conversion error.
Please help me out.
Begin
declare @tmptble TABLE(EmpId nvarchar(10),EmpMonth numeric(2,0),EmpYear numeric(4,0))
insert into @tmptble(EmpId,EmpMonth,EmpYear)
select emp_CDSID,MONTH(getdate()),YEAR(getdate()) from Employee
declare @count numeric(2,0)
declare @empid nvarchar(10)
declare @month numeric(2,0)
declare @year numeric(4,0)
set @count = (select count(*) from @tmptble)
declare FirstCursor cursor for select EmpId,EmpMonth,EmpYear from @tmptble
open FirstCursor
while (@count>0)
begin
fetch FirstCursor into @empid,@month,@year
set @existsAttendance = (select count(*) from Attendance where EmpId=@empid and EmpMonth=@month and EmpYear=@year)
if (@existsAttendance = 0)
begin
Insert into CDSI_DB.dbo.Attendance(EmpId,EmpMonth,EmpYear,SG,S1,S2,W,W1,W2,LOP,CO,SPL,OD,H) values(UPPER(@empid),@month,@year,0,0,0,0,0,0,0,0,0,0,0)
end
set @count=@count-1
end
close FirstCursor
End
And, "Attendance table has EmpMonth and EmpYear as numeric datatype.