SQL Server error 1006 means the CREATE TRIGGER statement you tried to run contains no statements in its body. A trigger must have at least one Transact-SQL statement between BEGIN and END (or as its body). The fix is to add the logic the trigger should run, then execute the batch again. This guide walks you through that fix step by step, plus how to avoid the error in the first place.
What You'll Need
- Access to SQL Server Management Studio (SSMS) or another client such as Azure Data Studio, with permission to create triggers on the target table (typically ALTER permission on the table).
- The name of the table and the trigger logic you intend to run (for example, an audit insert, a validation check, or a cascading update).
- Optional but recommended: a non-production copy of the database to test the trigger before deploying it.
Step-by-Step
- Reproduce the error and capture the exact statement. Run the CREATE TRIGGER batch that failed. The error message will say something like “The CREATE TRIGGER statement contains no statements.” Copy the full batch into a text editor so you can inspect it.
- Locate the trigger body. In your batch, find the section between AS and the end of the statement. A typical structure looks like:
CREATE TRIGGER trg_Example ON dbo.TableName AFTER INSERT AS BEGIN END
If you see BEGIN and END with nothing between them, that is the cause. - Decide what the trigger should do. Common choices: insert a row into an audit table, update a modified date column, or validate data and roll back if invalid. Write the logic as a single T-SQL statement or a block of statements. For example, to log inserts:
INSERT INTO dbo.AuditLog (TableName, Action, ChangedAt) SELECT 'TableName', 'INSERT', GETDATE(); - Insert the statement(s) between BEGIN and END. Keep the BEGIN/END block even for a single statement; it makes the trigger easier to read and extend. If you prefer, you can omit BEGIN/END and place a single statement directly after AS, but the block form is clearer.
- Check for syntax issues that can mimic an empty body. A stray semicolon immediately after AS, or a comment that swallows the rest of the line, can make the body appear empty. Ensure the first statement follows AS (or BEGIN) directly, and that no unclosed comment or string literal hides it.
- Run the corrected batch. Execute the full CREATE TRIGGER statement in SSMS. If it succeeds, you will see a “Commands completed successfully” message. The trigger is now active.
- Test the trigger. Perform the action that should fire it (for example, insert a row into the table). Then query the audit table or check the modified column to confirm the trigger ran as intended. If it did not, check that the trigger is enabled (see Troubleshooting).
- Save the working script. Store the corrected CREATE TRIGGER statement in source control or a scripts folder so you can recreate it in other environments without repeating the error.
Common Mistakes
- Leaving BEGIN/END empty. The most direct cause: the body has no statements. Always include at least one statement.
- Putting a semicolon right after AS. In some versions, a semicolon immediately after AS can cause the parser to treat the body as empty. Remove it or move it after the first statement.
- Using a comment as the only content. A comment is not a statement. The trigger still needs executable code.
- Forgetting that the trigger fires per statement, not per row. In SQL Server, triggers fire once per statement, and the inserted/deleted pseudo-tables can contain multiple rows. Write set-based logic, not row-by-row assumptions.
- Not schema-qualifying objects. Referencing tables without the schema (for example, AuditLog instead of dbo.AuditLog) can lead to resolution errors that look like other problems. Qualify names explicitly.
- Creating the trigger in the wrong database. Ensure you are connected to the correct database before running the batch, or use a fully qualified name.
Tips
- Keep triggers short and focused. Heavy logic in a trigger can slow down every insert, update, or delete on the table.
- Use SET NOCOUNT ON at the start of the trigger body to avoid extra result sets that can confuse client applications.
- Test triggers on a copy of the database first, especially if they modify other tables.
- Document each trigger with a comment block above the CREATE statement explaining its purpose and the tables it touches.
- Remember that triggers can be nested or recursive; check the database settings if you see unexpected behavior.
Troubleshooting
If the CREATE TRIGGER still fails after adding statements, check these points in order:
- Syntax errors elsewhere in the batch. A missing parenthesis or an unclosed quote earlier in the batch can make the parser misinterpret the trigger body. Run the batch through a parser or check the Messages tab for the first error.
- Permissions. You need ALTER permission on the table. If you are unsure, ask your database administrator.
- Trigger already exists. If a trigger with the same name exists, use DROP TRIGGER IF EXISTS (available in newer SQL Server versions) or drop it manually before creating. Dropping a trigger is a schema change; do it in a test environment first if possible.
- Trigger created but not firing. Check that the trigger is enabled: query sys.triggers and look at the is_disabled column. You can enable it with ALTER TABLE ... ENABLE TRIGGER trigger_name. Also confirm the trigger is attached to the correct table and that the operation (INSERT, UPDATE, DELETE) matches what you are testing.
- Error 1006 persists with a non-empty body. Try simplifying the body to a single PRINT statement to isolate whether the issue is the body content or the surrounding batch. If the simple version works, add your logic back piece by piece.
Frequently Asked Questions
What exactly does error 1006 mean?
It means the CREATE TRIGGER statement has no executable statements in its body. SQL Server requires at least one statement between AS and the end of the trigger definition.
Can I create a trigger with only a comment?
No. A comment is not a statement. You need at least one T-SQL command, such as SELECT, INSERT, UPDATE, DELETE, or PRINT.
Does this error occur in other SQL Server versions?
Yes, the requirement for a non-empty trigger body is standard across SQL Server versions. The exact error number may appear in different contexts, but the fix is the same.
How do I check if a trigger already exists?
Query the sys.triggers catalog view, for example: SELECT name FROM sys.triggers WHERE name = 'trg_Example';. You can also use OBJECT_ID('trg_Example', 'TR') to check for existence.
What is the difference between AFTER and INSTEAD OF triggers?
AFTER triggers run after the triggering statement completes; INSTEAD OF triggers replace the triggering statement. Both require a non-empty body, so error 1006 applies to both.
Can I use a trigger to prevent inserts?
Yes, you can use an INSTEAD OF trigger or an AFTER trigger with a ROLLBACK statement. However, be careful with ROLLBACK in triggers as it can have side effects; test thoroughly.