as above having problems

when i plug the sensor into the idle speed control valve the revs shoot straight up to about 2000 but when i unplug it again they go back down to about 700 to 800 wich is a lot better but the engine struggles a little.
i have taken it off and cleaned it but no different
any ideas
cheeRS alan