Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SQL Server Error 1727: Fix Non-Clustered Index Creation

· 4 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

SQL Server error 1727 means the non-clustered index you are trying to create uses an option that is not allowed for that index type. The most common cause is specifying ONLINE = ON, ALLOW_ROW_LOCKS, ALLOW_PAGE_LOCKS, or IGNORE_DUP_KEY in a way the index type does not support. The fix is to remove or change the unsupported option in your CREATE INDEX statement, then run it again. This guide walks through identifying the exact option at fault and rebuilding the index correctly.

What You'll Need

  • SQL Server Management Studio (SSMS) or Azure Data Studio connected to the database.
  • Permission to create indexes on the table (typically ALTER on the table or membership in db_ddladmin).
  • The original CREATE INDEX statement or script that produced the error.
  • A maintenance window if the table is large, because rebuilding an index can lock the table.

Step-by-Step

  1. Read the full error message. Error 1727 usually names the offending option, for example "Cannot create nonclustered index ... because the option 'ONLINE' is not supported." Note the exact option and the index name.
  2. Open your index script. Locate the CREATE NONCLUSTERED INDEX statement for that index. It may be in a deployment script, a migration file, or a manual query window.
  3. Check the WITH clause. Look for options such as ONLINE = ON, ALLOW_ROW_LOCKS, ALLOW_PAGE_LOCKS, IGNORE_DUP_KEY, FILLFACTOR, or DROP_EXISTING. One of these is likely the culprit.
  4. Remove or adjust the unsupported option. For example, change ONLINE = ON to ONLINE = OFF (the default), or delete the ALLOW_ROW_LOCKS and ALLOW_PAGE_LOCKS lines. If the option is required for your workload, check the SQL Server version and edition: some options are only supported on Enterprise edition or on newer versions.
  5. Verify the index type. Confirm you are creating a non-clustered index and not a special type such as a filtered index, columnstore index, or XML index, which have their own option restrictions. If the table already has a clustered index, a non-clustered index can still be created; the error is about the option, not the table structure.
  6. Run the corrected statement. Execute the CREATE INDEX in SSMS. If it succeeds, the error is resolved.
  7. Update the source script. If the failing statement came from a deployment or migration file, edit that file so the same error does not recur on the next deployment.

Common Mistakes

  • Assuming the table is the problem. Error 1727 is almost always about an index option, not about the table lacking a clustered index.
  • Leaving ONLINE = ON in a script copied from Enterprise edition. Online index rebuilds are edition- and version-dependent; on editions that do not support it, the statement fails.
  • Ignoring the exact option named in the message. Changing unrelated settings wastes time; fix the option the error names.
  • Forgetting to update deployment scripts. The error returns on the next release if the source file is not corrected.

Tips

  • Test index scripts on a development copy before running them in production.
  • Use SET STATISTICS IO ON and SET STATISTICS TIME ON to measure the impact of the new index.
  • Keep index creation scripts in version control so option changes are traceable.
  • If you need online index operations, confirm your SQL Server edition and version support them before relying on ONLINE = ON.

Troubleshooting

If the error persists after removing the obvious option, check for a second WITH clause or a nested script that re-adds the option. Run sp_helpindex 'YourTable' to see existing indexes and confirm the index name is not already in use. If the error mentions a filtered index, verify the filter predicate is valid and that the option you are using is allowed for filtered indexes. If you are deploying through a tool, inspect the generated SQL it sends to the server, because the tool may add options you did not write. When in doubt, simplify the statement to a bare CREATE NONCLUSTERED INDEX ... ON ... (columns) with no WITH clause, confirm it works, then add options back one at a time.

Frequently Asked Questions

What does SQL Server error 1727 mean?

It means the non-clustered index statement includes an option that is not supported for that index or for your SQL Server edition or version.

Does error 1727 mean my table has no clustered index?

No. The error is about an unsupported index option, not about the absence of a clustered index.

Can I create a non-clustered index on a table without a clustered index?

Yes. A non-clustered index can be created on a heap (a table with no clustered index). The error is unrelated to that.

Why does ONLINE = ON cause error 1727?

Online index operations are not supported on every SQL Server edition or version. If your edition does not support it, the statement fails with error 1727.

How do I find which option caused the error?

Read the full error text; it usually names the option. If not, remove options from the WITH clause one at a time and retest.