Database : CASKoenigDB
DECLARE @TrainerID INT
DECLARE @CourseSDate DATETIME
DECLARE @CourseEDate DATETIME
Declare @GDate datetime
DECLARE @LocationId INT
CREATE TABLE #tbl1 (TrainerID INT,GDate DATETIME, LocationId INT)
DECLARE LDates CURSOR
FOR
SELECT IC.TrainerId ,IC.CourseSDate,IC.CourseEDate,IC.LocationId
FROM TRAN_SCINTERESTEDCOURSES IC
WHERE IC.LocationId IN (1,2,3,4,5,6) AND IC.TrainerId IS NOT NULL AND IC.CourseSDate>'2016-03-31'
AND CourseEDate<='2016-04-30' ORDER BY IC.CourseSDate
OPEN LDates
FETCH NEXT FROM LDates
INTO @TrainerID,@CourseSDate,@CourseEDate,@LocationId
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #tbl1
SELECT TrainerID ,trngdate,LocationId
FROM getFullMonthforRC(@TrainerID,@CourseSDate,@CourseEDate,@LocationId)
FETCH NEXT FROM LDates
INTO @TrainerID,@CourseSDate,@CourseEDate,@LocationId
END
CLOSE LDates
DEALLOCATE LDates
SELECT * FROM #tbl1
DROP TABLE #tbl1
DECLARE @TrainerID INT
DECLARE @CourseSDate DATETIME
DECLARE @CourseEDate DATETIME
Declare @GDate datetime
DECLARE @LocationId INT
CREATE TABLE #tbl1 (TrainerID INT,GDate DATETIME, LocationId INT)
DECLARE LDates CURSOR
FOR
SELECT IC.TrainerId ,IC.CourseSDate,IC.CourseEDate,IC.LocationId
FROM TRAN_SCINTERESTEDCOURSES IC
WHERE IC.LocationId IN (1,2,3,4,5,6) AND IC.TrainerId IS NOT NULL AND IC.CourseSDate>'2016-03-31'
AND CourseEDate<='2016-04-30' ORDER BY IC.CourseSDate
OPEN LDates
FETCH NEXT FROM LDates
INTO @TrainerID,@CourseSDate,@CourseEDate,@LocationId
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #tbl1
SELECT TrainerID ,trngdate,LocationId
FROM getFullMonthforRC(@TrainerID,@CourseSDate,@CourseEDate,@LocationId)
FETCH NEXT FROM LDates
INTO @TrainerID,@CourseSDate,@CourseEDate,@LocationId
END
CLOSE LDates
DEALLOCATE LDates
SELECT * FROM #tbl1
DROP TABLE #tbl1
No comments:
Post a Comment