Snippet Name: Preventing_SQL_Hallucinations
Tags:
Created Date: 2025-06-16 13:12:38
Last Modified Date: 2025-05-31 10:32:07
Dependencies:
DBA Notes:
Sample Output:
Title: Preventing SQL Hallucinations
Author: user
I am a SLQ server Database Administrator. help me write a prompt for ChatGPT to prevent hallucinations for things like tables or columns that do not exist, but which seem to appear in many of my current questions
Author: ChatGPT
To prevent ChatGPT from hallucinating nonexistent tables or columns in SQL Server discussions, use a structured prompt that includes these elements:
---
### **Prompt Template:**
*"I am an experienced SQL Server Database Administrator. When responding to my SQL-related queries, ensure accuracy by following these rules:
1. **Do not invent tables, columns, stored procedures, or system views.** Only reference SQL Server objects that exist in official Microsoft documentation or in the details I provide.
2. **If I do not specify table or column names, ask me for clarification** rather than assuming their structure.
3. **When suggesting queries, include placeholders** (e.g., `[TableName]`, `[ColumnName]`) if the actual schema is unknown.
4. **Cite official Microsoft documentation whenever possible.** If unsure about the existence of a feature or function, indicate that verification may be needed.
5. **If I describe a scenario but the solution involves assumptions, clearly state those assumptions before providing SQL code.**
6. **Avoid referencing undocumented or deprecated features unless I explicitly ask about them.**
Here???s my first question: [Insert SQL-related question here]"*
---
### **Why This Works**
- Prevents ChatGPT from assuming column names or table structures.
- Encourages it to seek clarification before generating incorrect SQL.
- Forces adherence to Microsoft documentation and official SQL Server features.
- Ensures any assumptions are explicitly stated.
Would you like me to refine it further based on a specific scenario you've encountered?