Cursor And Date Function MS-SQL

/*
Select * from Employee Where userName = '나정탁'
Select * from WH_Workcode
Select * from WH_Workhistory Where WWH_WC_CD = 10
Select * from CompanyDiary
*/


Declare @FirstDate DateTime
Declare @LastDate DateTime
Declare @AddDate INT
Declare @Return INT
Declare @UserID NVarchar(12)
Declare @WC_CD INT
Declare @TS_CD INT
Declare @YYYY INT, @MM INT, @DD INT

SET @FirstDate = '2004-11-01'
SET @LastDate = '2005-01-31'
SET @AddDate = 1
SET @UserID = 'spprigun'
SET @WC_CD = 10
SET @TS_CD = 1 --반차, 조퇴 등 이외 의미 없음

While @FirstDate <= @LastDate
Begin
IF (DATENAME ( dw , @FirstDate ) != '토요일') And (DATENAME ( dw , @FirstDate ) != '일요일')
Begin
--장기 출장 등록자 한번에 처리
SET @YYYY = Year(@FirstDate)
SET @MM = Month(@FirstDate)
SET @DD = Day(@FirstDate)

Execute @Return = WH_Set_HolidayReg_sp @UserID, @WC_CD, @TS_CD, @YYYY, @MM, @DD
--에러 난 부분 리턴
IF @Return != 1 Begin
Select @UserID, @FirstDate
End

End
SET @FirstDate = DateAdd(dd, @AddDate, @FirstDate)
End