Sugar and working out? Does one cancel out the other?

Someone, if anyone tell me when you consume sugar like a soda, does that ruin your workout? That is one of those thing I've heard before and never found out the true answer. To this day,I think that's why when I slip up and eat something I know I shouldn't have I say: I guess there is no need to exercise. Somebody please confirm or deny this. I think it may be really helpful to me...seriously