I have been hosting in a server from last 2 years. I am planning to change the hosting server. Before I change the hosting server I would like to know whether it affects my site's rankings or not?
As long as your domain name and hosting country stay the same, switching from one reliable host to another should have no SEO impact. See question 4 in this Seomoz article link
No. And why should it? Your hosting has nothing to do with the quality or relevancy of your content. (1)
Just try to minimize downtime and avoid if possible. A seamless transition is ideal.
(1) Really slow loading webpages may cause google to lower your page rankings but you have to be in the bottom 1% or so for this to happen. So as long as your host isn't poor you will be fine.
In a similar vein as John Conde's suggestion (though picking up on a few things I've noticed) you can also expect problems when switching hosts if your new host has security issues.
If you share an Apache server with malicious users, you may find some problems including malicious content apparently hosted under your domain if your host has not disabled features like Apache's mod_userdir (it doesn't help to be recognized as a phishing or malware site)
Yes. Actually, it can!
If the new host is permissive and has issues with quality sites, hacker activity, spamming (all types), and past issues with search engines, your site could be given an IP address that is either specifically known or within a block that is known as a bad neighborhood. As well, the host itself can be considered as a bad neighborhood. Google tracks not only IP addresses and IP address blocks, but hosts that are known for these issues. Not choosing a high quality host can literally drop you from search existence almost over night (actually over a period of just a few days). This is also true for using a CDN and is quite common.