NHS boards spent more than £38,000 a day on consultants' overtime in the past three years, according to figures collated by the Scottish Liberal Democrats.
Statistics gathered from nine out of 14 health boards show that between 2014/15 and 2016/17, a total of £42,394,057 was spent on the overtime bill.
The highest amount was recorded in 2015/16, at more than £15.2 million, dropping to more than £12.3 million last year.
The Lib Dems called on ministers to "mend their chronically chaotic approach" to workforce planning in the NHS.
The Scottish Government said overtime payments should be seen in the context of the health service's £6.5 billion annual staffing bill.
Data published in December showed Scotland's hospitals saw vacancies for consultants rise by 10% over a year, with more than 250 posts lying empty for at least six months.
Lib Dem health spokesman Alex Cole-Hamilton said: "There will always be times when overtime is necessary to cover short term gaps in the workforce, but official statistics show that hundreds of consultant posts have been empty for six months or more.
"This money could be better invested in ensuring NHS boards have enough permanent staff in the first place. It could pay for at least 400 additional consultants.
"This sizeable bill shows why SNP Ministers must mend their chronically chaotic approach to workforce planning."
A Scottish Government spokeswoman said: "NHS staff numbers in Scotland are at a record high level and Scotland is leading the way on workforce planning - as the first nation in the UK to publish a national health and care workforce plan, but also the only one committed to safe staffing legislation that covers both health and care settings.
"Annually, the NHS spends over £6.5 billion on staffing, and any payments made for overtime should be seen in that context."