Select the top rows from your select query
SELECT TOP 1 ELG_ORDER FROM HS_HR_BM_MEDICAL_ELG_DST WHERE EMP_NUMBER = @EMP_NUMBER ORDER BY ELG_ORDER DESC
Saturday, May 5, 2012
SQL CURSOR Syntax
Follow the below MS SQL syntax for create new Cursor
DECLARE emFIRST CURSOR FOR
SELECT EMP_NUMBER FROM HS_HR_EMPLOYEE
OPEN emFIRST
FETCH NEXT FROM emFIRST INTO @EMP_NUMBER
WHILE (@@fetch_status <> -1)
BEGIN
SELECT @CORPORATE = CT_CODE FROM HS_HR_EMPLOYEE
PRINT @EMP_NUMBER
PRINT '---------------------'
FETCH NEXT FROM emFIRST INTO @EMP_NUMBER
END
CLOSE emFIRST
DEALLOCATE emFIRST
DECLARE emFIRST CURSOR FOR
SELECT EMP_NUMBER FROM HS_HR_EMPLOYEE
OPEN emFIRST
FETCH NEXT FROM emFIRST INTO @EMP_NUMBER
WHILE (@@fetch_status <> -1)
BEGIN
SELECT @CORPORATE = CT_CODE FROM HS_HR_EMPLOYEE
PRINT @EMP_NUMBER
PRINT '---------------------'
FETCH NEXT FROM emFIRST INTO @EMP_NUMBER
END
CLOSE emFIRST
DEALLOCATE emFIRST
Subscribe to:
Posts (Atom)