LimeSurvey LSS Import 500 Database Error, Explained
A 500 database error during LSS import — with the survey and questions created but answer options missing — almost always means the answers insert failed. The two verified causes: answer codes longer than LimeSurvey's 5-character column, and multiple-choice options placed in the wrong table.
Why the survey half-imports
LimeSurvey's importer walks the LSS file table by table: surveys → groups → questions → subquestions → answers → conditions. Inserts are not wrapped in one transaction. When an answers row violates a database constraint, the import aborts at that point — after the survey, groups, questions, and subquestions are already stored. The result is the exact symptom users report: the survey exists, the questions exist, and every answer list is empty.
Causes and fixes
| Symptom | Root cause | Fix |
|---|---|---|
| 500 error; survey + questions created; options missing | answers.code exceeds the 5-character column limit ("Data too long for column 'code'") | Shorten answer codes to ≤5 alphanumeric characters (or let a converter fall back to ordinal codes) |
| Import "succeeds" but multiple-choice questions are empty | Type M options were written to the answers table; LimeSurvey expects them as subquestions | Regenerate the LSS with options emitted as subquestions with the parent's type |
| Answer text blank on LimeSurvey 6 | File carries answer text only in answers.answer, but LimeSurvey 6 reads answer_l10ns when that section exists | Use a LimeSurvey 6 layout: answers rows plus matching answer_l10ns rows with aligned aid values |
| Import rejected for older LimeSurvey | DBVersion / table layout newer than the installed LimeSurvey generation | Export a legacy-layout LSS (answer text inline in answers.answer with a language column) |
The 5-character limit comes straight from the LimeSurvey schema: the answers table defines code as string(5) NOT NULL, with an index on qid + code + scale_id. AI-generated or hand-written files that use descriptive codes like option_one hit this immediately.
Verification checklist before import
- Every answer option code is 1–5 alphanumeric characters.
- Multiple-choice (M) questions have their options as subquestions rows whose type matches the parent question.
- On LimeSurvey 6 layouts, each answers row has a matching answer_l10ns row with the same aid.
- Question and group counts match the source questionnaire.
- Import into a test survey and preview every choice question before production use.