More than 400,000 people have been placed on a police "vulnerable persons" database, an investigation has found.

Officers add people they encounter at incidents to the Interim Vulnerable Persons Database (iVPD) if they are concerned for their future wellbeing.

The database also records incidents where there has been an immediate crisis response for issues of adult or child protection, domestic abuse, hate crime or youth offending.

Police can share "relevant, necessary, justifiable and proportionate information" with partner agencies where there is a legal basis to do so.

The Information Commissioner has raised concerns that the database breached the Data Protection Act over how long data is kept and has spoken to Police Scotland about the issue.

The BBC investigation found that there are currently 412,000 adults and children on the database, up from 302,346 in February last year.

Assistant Chief Constable Nelson Telfer said: "The Interim Vulnerable Persons Database (iVPD) was designed as an interim solution by Police Scotland to assist in consolidating previous recording practices across each former Force area.

"iVPD is an incident based database that records information about individuals who are, or are perceived to be experiencing adverse circumstances or situational vulnerabilities which may impact on their current or future wellbeing.

"It also records incidents where there has been an immediate crisis response required in respect of adult or child protection; domestic abuse; hate crime; youth offending and is used to record details of victim's rights under Section 8 and 9 of the Victims and Witnesses (Scotland) Act 2014.

"Police Scotland's officers and staff come into contact with thousands of people every day. Officers will raise a concern when they believe there may be a wellbeing or protection issue."

He said not all information recorded on the database is shared with partner agencies, and that information sharing is governed by the Data Protection Act 1998 and Human Right Act 1998.

He added: "Where there is a legal basis to, Police Scotland will share relevant, necessary, justifiable and proportionate information with partners to secure appropriate intervention with statutory requirements and national guidance.

"The database provides visibility across Scotland and maximises opportunities to provide early intervention, prevention and reduce harm."

An Information Commissioner's Office spokesman said: "Data protection law protects the public by setting out rules that personal data must not be kept for longer than necessary.

"We have spoken to Police Scotland and advised how they can bring the interim vulnerable persons database into compliance with the Data Protection Act."