Car had a flat battery after being left in garage for 3 weeks, I don't think I left anything switched on but I've now been trickle charging for a couple of days and will have a go later and see how it goes.

If I haven't left anything on to cause a drain is this an early sign of a defective battery?

And if I do have to get one is there anything I need to know about changing it over ie will I lose any codes or have to reset anything?

Alan,
It sounds like your battery could well be on it's last legs. MIne did exactly that a couple of years ago, but it was the original BMW battery, so it had lasted well.
Check that nothing is switched on & also that your boot light is going out as it should. A good way of doing that is by putting your mobile onto video record & closing the boot lid with it inside to see that the light goes off.
If you do have to get a new battery, you will most likely have to put the radio security code in afterwards if you still have the original BMW head unit in your car.
If you are planning to store your car for a while, I would recommend using a smart charger like one of the CTEK models. They plug into your cigar lighter socket & cycle the battery through charge/discharge cycles to keep it healthy.
I use one all winter while my car is stored. It keeps the battery in excellent condition.
I hope this helps.

Mine conked out last Sunday which was the original 13 year old BMW battery. It had been on cTEK charger since March and started fine but next day it was completely dead. Had the battery tested by the RAC who said one of the cells/plates had failed. Sounds like they just suddenly fail. They fitted a new uprated battery with their own 5 year warranty. Nothing will need recoding except your ICE if it needs an anti theft code. I have a Becker unit fitted and put the code in wrong 3 times and then realised the handbook the code is written is doesn't belong to the head unit Bit of a pain as I've now got to wait an hour with the ignition on so that I can put the correct code in

What I've done in the past is if you can
Get hold of a battery jump starter put it
On to the battery lead connection in the
Engine bay putting power to the car remove
The battery from the boot fit your new one
Then disconnect the jump starter all through
The process you'll have power to the car

Alan W wrote:Car had a flat battery after being left in garage for 3 weeks,.............

Don't write your battery off yet. After 3 weeks - idle drain will flatten a battery particulary if not fully charged to start with. If you search the forums you will find a number of threads which contain `idle drain' rate comments.

Agree, don't give up just leave it on a slow charge. I normally have my battery sat on a trickle charge but left it off for a couple of weeks and it went flat. A couple of days on the trickle charge and it was back to normal. You do need a good quality charger to recover a battery that is flat.

Alan W wrote:Car had a flat battery after being left in garage for 3 weeks, I don't think I left anything switched on but I've now been trickle charging for a couple of days and will have a go later and see how it goes.

If I haven't left anything on to cause a drain is this an early sign of a defective battery?

And if I do have to get one is there anything I need to know about changing it over ie will I lose any codes or have to reset anything?