Why This Error Happens
This error occurs because SQL Server 2025 does not allow a computed column to reference another computed column within a new computed-column definition—it only permits references to base (physical) columns. The engine enforces this restriction to avoid circular dependency chains and to guarantee deterministic evaluation order when the table schema is compiled. This typically surfaces during CREATE TABLE or ALTER TABLE statements when a developer nests computed logic instead of referencing the underlying raw column.
Step-by-Step Resolution Guide
Step 1: Identify the Offending Computed Columns
- Open SQL Server Management Studio (SSMS) or Azure Data Studio and run the failing
CREATE TABLE/ALTER TABLEscript to capture the exact error message, which includes the specific column and table names. - Query the system catalog to inspect existing computed column definitions:
SELECT name, definition, is_persisted
FROM sys.computed_columns
WHERE object_id = OBJECT_ID('YourTableName');
- Note which computed column is being referenced inside the new computed-column formula.
Step 2: Rewrite the Computed Column to Reference Base Columns
- Edit the
ASexpression of the problematic computed column so it points directly to the original physical (base) column(s) rather than the other computed column. - Example of the invalid pattern:
ALTER TABLE dbo.Orders
ADD TotalWithTax AS (TotalPrice * 1.08); -- TotalPrice is already computed
- Corrected version, referencing the raw columns used to build
TotalPrice:
ALTER TABLE dbo.Orders
ADD TotalWithTax AS (Quantity * UnitPrice * 1.08);
Step 3: Flatten Nested Logic Using a View or Persisted Column
- If the calculation is complex and reused often, consider materializing the base computation into a
PERSISTEDcomputed column (this does not fix nesting but can simplify logic) and move the secondary calculation into a SQLVIEWor application-layer query instead of a second computed column. - Example using a view:
CREATE VIEW vw_OrdersWithTax AS
SELECT *, (Quantity * UnitPrice * 1.08) AS TotalWithTax
FROM dbo.Orders;
Step 4: Validate Schema Changes in a Non-Production Environment
- Run the corrected
ALTER TABLEorCREATE TABLEscript against a staging/test instance running SQL Server 2025 on Windows Server 2025 or Windows 11 first. - Check the SQL Server Error Log located at
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Log\ERRORLOGfor any residual schema compilation warnings.
Alternative or Verification Steps
- Re-run the original
CREATE TABLE/ALTER TABLEscript; if it completes without Error 1759, querysys.computed_columnsagain to confirm the new column was created successfully. - If nested calculations are unavoidable for business logic, use a
SELECTstatement with inline expressions or a scalar function at query time instead of chaining computed columns at the schema level.