Shortages of specialist beds sometimes mean patients are moved to other departments.
But Labour said a government study had shown the practice – known as boarding out – was likely to see patients more at risk of dying, more likely to spend longer in hospital and also more likely to be readmitted after being sent home.
The party said the figures for boarding out – obtained under Freedom of Information – showed the “huge strain” hospitals were under.
Lothian Labour MSP Sarah Boyack said: “It’s of real concern to find that over 14,000 patients were boarded over this two-year period.
“Medical experts including the Royal College of Physicians of Edinburgh have warned the practice can result in negative outcomes for patients including longer stays in hospital.
“The scale of boarding in NHS Lothian adds weight to the concerns raised consistently by staff that hospital wards are having difficulty in dealing with the level of demand. We need action from the Scottish Government to ensure that our NHS is properly resourced so that patients get the specialised care they need at all times.”
Daniel Johnson, Labour candidate for Edinburgh Southern in the Holyrood elections, said the figures pointed to huge levels of stress in hospitals.
He said: “We know that only a third of NHS staff believe they have the resources to do their jobs properly. This information suggests that too often there isn’t enough space for patients to be treated in the appropriate ward. That is hugely concerning.
“Scottish Labour would give our NHS established in the 1940s, the tools it needs to face the challenges of the 2040s. This starts with substantial investment in social care.
“Greater investment in social care would take significant pressure off of our hospitals and that starts with delivering a national care workers’ guarantee on wages, terms and conditions.”
Jim Crombie, chief officer of acute services at NHS Lothian, said: “We recognise that boarding patients is not ideal, but it is sometimes necessary in order to manage capacity and this is particularly true in winter months.”.
“Patients are assessed on an individual basis and we work hard to ensure that more vulnerable people are not moved into non-specialist wards unless it is absolutely necessary.
“It is important to note that the situation can change quickly as patients are discharged and new patients are admitted.
“We are also working with our colleagues in the Integrated Joint Boards to ensure that more patients can be returned home as soon as they are ready to be discharged or move to the most appropriate setting for them as quickly and safely as possible.”