Troubleshooting Guide: Error 11437 – “Cannot alter table because at least one column must be declared as non-hidden”
Why This Error Happens
This error occurs when an ALTER TABLE statement attempts to hide every column in a table using the HIDDEN attribute, leaving no visible columns for standard SELECT * operations or implicit data access. SQL Server 2025 enforces a schema integrity rule requiring at least one non-hidden column to remain in every table to preserve backward compatibility with applications and queries that rely on default column enumeration. This typically happens during schema migrations, column obfuscation scripts, or automated DevOps pipelines that loop through all columns and mark them as hidden without excluding at least one.
Step-by-Step Resolution Guide
Step 1: Identify the Offending ALTER TABLE Statement
- Review the T-SQL script or migration tool output that triggered Error 11437.
- Check SQL Server Management Studio (SSMS) 21 “Messages” tab or the SQL Server error log at
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOGfor the exact table name referenced in the error. - Run the following to inspect current column visibility status:
SELECT name, is_hidden FROM sys.columns WHERE object_id = OBJECT_ID('YourTableName');
Step 2: Designate At Least One Column as Non-Hidden
- Modify your
ALTER TABLEscript to explicitly exclude a primary key or frequently queried column from theHIDDENattribute. - Example fix:
ALTER TABLE dbo.YourTableName
ALTER COLUMN YourPrimaryKeyColumn INT NOT HIDDEN;
- If using a loop-based migration script (PowerShell or SQLCMD), add a conditional exception for the first or last column in the iteration.
Step 3: Audit Automated Scripts and ORM Mappings
- Check Entity Framework Core or Dapper migration files under your project’s
Migrationsfolder for logic that appliesHIDDENglobally. - Update any schema-generation templates (e.g.,
.sqlprojfiles in SQL Server Data Tools) to skip at least one mandatory visible column by default. - Re-deploy the corrected migration using
sqlpackage.exeor your CI/CD pipeline.
Step 4: Apply the Corrected Schema Change
- Execute the revised
ALTER TABLEstatement in SSMS or viasqlcmd -S localhost -d YourDatabase -i FixedScript.sql. - Confirm no errors are returned and the command completes successfully.
Alternative or Verification Steps
- Verify the fix by re-running
SELECT name, is_hidden FROM sys.columns WHERE object_id = OBJECT_ID('YourTableName');and confirming at least one row showsis_hidden = 0. - If the error persists, drop and recreate the table using a full
CREATE TABLEstatement with explicit column visibility defined upfront, then migrate data usingINSERT INTO ... SELECTfrom a backup copy.