They are different because the chemical formula of sodium chloride is NaCl whereas that of sugar is C12H22O11.
They differ in chemical properties but they have same appearance.
Also if we salt instead of sugar then the taste of the food goes very bad.....
Hence sugar and sodium chloride are different even though they have same appearance.
HOPE U LIKED THE ANSWER :D