In the UK the Railways and Transport Safety Act 2003 is the relevant legislation.
From that Act
A person commits an offence if he performs an aviation function at a time when his ability to perform the function is impaired because of drink or drugs, or he carries out an activity which is ancillary to an aviation function at a time when his ability to perform the function is impaired because of drink or drugs.
A person commits an offence if he performs an aviation function at a time when the proportion of alcohol in his breath, blood or urine exceeds the prescribed limit, or he carries out an activity which is ancillary to an aviation function at a time when the proportion of alcohol in his breath, blood or urine exceeds the prescribed limit.
The prescribed limit of alcohol for pilots is
breath, 9 microgrammes of alcohol in 100 millilitres,
blood, 20 milligrammes of alcohol in 100 millilitres
urine, 27 milligrammes of alcohol in 100 millilitres.