Add onions and garlic and cook until it turns brown.
Add corned beef and break into pieces with the back of a spoon.
Add spaghetti sauce and cook for about 3 to 5 minutes or until heated through.
Add sugar. Season with salt and pepper to taste.
In another pot over medium heat, cook spaghetti according to package directions in boiling water for about 7 to 10 minutes or until al dente. Drain well.
To serve, transfer spaghetti onto a serving platter, spoon sauce over pasta and sprinkle cheese on top.