The first recorded mention of Sandhausen (or "Santhusen") was in . Sandhausen is named after the ice-age sand dunes that border the municipality. As early as Roman times, a settlement called "Lochheim" existed in the area. It was part of
Bishopric of Speyer till 1262, when Otto von Bruchsal gave it to
Ludwig II,
Electoral Palatin. It was part of Oberamt Heidelberg in 1351. It was sacked by Baden and Württemberg troops in the
Mainz Diocesan Feud in 1462. It was again sacked by Spanish troops during the
Thirty Years' War in 1622 and by French troops during the
Nine Years' War in 1688. French troops remained in Sandhausen until 1697. After the death of
Maximilian III, Elector of Bavaria, head of the Bavarian branch of the
House of Wittelsbach,
Charles Theodore, County Palatine of Rhine, inherited Bavaria in 1777 and the territories of the House of Wittelsbach were united under its Palatinate branch. Thus, Sandhausen became part of
Bavaria. It was occupied by French troops in 1795 and was awarded to the
Grand Duchy of Baden after
German mediatization in 1803. ==Politics==