More than half of patients on dedicated long-term wards had not been outside for at least a month when staff from a health watchdog visited them. Almost three-quarters had not left the hospital grounds in three months.
Some elderly men and women spent their days in rooms where they could not see through high windows, and many were on strong medication with potentially dangerous side-effects.
The revelations were among a raft of disturbing findings by the Mental Welfare Commission for Scotland about the treatment of patients in NHS continuing care dementia wards.
It follows serious concerns raised in another recent report, and highlighted by The Herald, about the treatment of patients with dementia symptoms at the Royal Edinburgh Hospital.
The report, Dignity and Respect: Dementia, was strongly critical of the practice of confining patients indoors.
"Opportunities to get outside must be an essential element of everyone's care. Too many people continue to spend long periods of time without any access to the world outside, either to a unit garden or further afield," it said.
The husband of one elderly woman told the research team: "My wife cannot go outside. The room window does not open, and my wife hasn't had fresh air in two years."
The commission was critical of two units, both unnamed, where communal areas were lit by skylights and windows so high up that patients could not see outside.
Staff from the watchdog visited 336 patients in all 52 continuing care dementia wards in Scotland. Settings included community, general and acute psychiatric hospitals and private care homes under contract to the NHS.
Across many they found poor standards of care, few activities for patients and an over-reliance on anti-psychotic medication - the side-effects of which include falls, strokes and an increased risk of death among elderly patients.
Some 84% of patients were on at least one "psychotropic" drug, while 34% were taking three different types. In many cases medication was not being regularly reviewed, contrary to guidelines.
Dr Gary Morrison, executive director (medical) at the Mental Welfare Commission, said: "Medication should be used as a last, not first, resort in the management of stressed and distressed behaviours, and should be carefully justified and regularly reviewed.
"There were significant levels of use of antipsychotics, anxiolytics and sedative antidepressants, often in combination. These medications all potentially carry risks of side-effects, particularly in older people."
Concerns were also raised about poor access to specialist staff such as occupational therapists, physiotherapists and psychologists as well as stark and shabby physical environments.
Henry Simmons, chief executive of Alzheimer Scotland, said he was "deeply disappointed by the extent of the problems highlighted".
He added: "We believe staff are being let down by a lack of investment in the resources required to deliver the highest quality of care and treatment."
The report made 20 recommendations, including the necessity of taking patients outdoors, treating them as individuals and reviewing medication every three months.
Ministers have attempted to improve the standard of care for dementia patients over recent years, and have published a national strategy.
However, disturbing cases of poor treatment emerge regularly. One 80-year-old woman, admitted to Ninewells Hospital in Dundee in December 2008, was denied food for 11 days and given sedatives 86 times over 16 days. She died of pneumonia later that month.
About 86,000 people in Scotland have dementia and one-third of them are in care homes or hospitals. The number of sufferers is expected to double over the next 20 years as the population ages.
As the MWC report was published, the Scottish Government announced an extra £500,000 for training staff working with dementia patients, including an additional £360,000 funding package over three years to Alzheimer Scotland's dementia nurses.
Minister for Public Health Michael Matheson said: "We are committed to transforming dementia services with a range of other activity in our current dementia strategy. I am confident that, with the continued support, professionalism and hard work of all those involved, we will continue to improve care and provide better support for people in our communities living with dementia."
Shortfalls in care at Royal Edinburgh Hospital were exposed by the family of one patient, Peter O'Malley, who died last October. His clothes were lost and he suffered repeated falls. NHS Lothian has apologised to his relatives.