It is generally the case, as with most things, that practice makes perfect.
I've been in your position, though, perhaps not identical. But today I can talk to anyone, anywhere, anytime. I started of with small steps. I mean, initially I had a hard time talking to my hairdresser! Now, I tend to be the center of parties.
I was really upset with the situation - which called for some serious actions! I did a lot of reading, primarily in relationships, dating etc. I think reading about dating is extremely wise. Being able to handle the opposite sex naturally, will benefit you in many different ways. It will make you a great deal more confident on many different venues.
Returning to those small steps, I started to build on with what I felt I was comfortable with. For example, I wasn't shy when I ordered a hamburger - and I'm fairly certain this applies to you too. So, whenever I did something like that, I tried to converse a little bit more than I used to. I started with small things like "have a nice day" (I don't know about UK, but in Sweden it is quite uncommon that ppl says things like that when they're buying a hamburger). It's not much, in fact, it's nothing. However, there's an immensely important concept here. You're actually saying things that you're not used to say, to other people. Also, you're doing things on a "plan towards being more socially comfortable". You're sort of tricking yourself into believing you're socially experienced. Are you following me? This will improve your self-esteem and confidence.
Now, you should aim higher as times goes by. E.g. when I started of I had long term goal, it was "be able to smoothly talk to the hottest chick in the pub". My short term goal was "when being introduced to someone, don't just say 'hi' - get to know the person(s)!".
As of yet, I can't walk straight up to the hottest chick in the pub and start a James Bond-like conversation. I can, however, enter a party where I know like max 5%, and just have fun, talk to everyone, get to know a lot people, getting phone numbers from nice girls etc.
What you have to do is to start a plan. Be conscious about that you want, but infintely more important
need, to improve your social skills. Whenever you're in a situation where you think "I better go now, because I want to avoid talking to this guy because I'm sooo shy", you better think to yourself "jeez.. what the f++k, stop being a wuss and let's go talk to this lad!".
I want to finish off with another example: during those shy-days, a woman, extremely good looking, walked up to me and asked "is this bus going to blablabla?". The shy-me would have said "yes" and then looked the other way. But I paused for a second, thought about it, and then said "yes it does, where are you going? blablabla is quite large, this one is perhaps not the optimal one"... then she said where she was going and we talked about that and so on.
Can you imagine the confidence boost? It was a walk in the park to talk to all the girls in the bar that evening.
Finally, Try to have the mindset that you a) want to improve your social skills, but more importantly b) that you need to learn something about the guy, you need to get to know him!
Most importantly, however, is to
have fun.
---
Knowing what to say is not about "knowing" something. Is all about confidence. You need to improve your confidence. See above

and good luck!