Hi @Spunny ,
Please try the following solution.
It will work starting from SQL Server 2012 onwards.
SQL
DECLARE @IDVar INT, @NameVar VARCHAR(50);
DECLARE @tbl TABLE (ID INT, [Name] VARCHAR(50));
INSERT @tbl (ID, [Name])
VALUES (1, 'Employee')
, (2, 'Department')
, (3, 'Class');
DECLARE @RowCount INT = (SELECT COUNT(*) FROM @tbl);
WHILE @RowCount > 0 BEGIN
SELECT @IDVar=ID, @NameVar=[Name]
FROM @tbl
ORDER BY ID DESC OFFSET @RowCount - 1 ROWS FETCH NEXT 1 ROWS ONLY;
-- do whatever needed, apply any logic, call stored procedures, etc.
/*
Exec usp_Employee @name = @NameVar
Exec usp_Department @ID = @IDVar,@name = @NameVar
*/
SET @RowCount -= 1;
END