1. An engineering team has a SQL Database Project using the SDK-style model. A developer has introduced a new schema change on a feature branch that renames the column dbo.Orders.CustomerRef to dbo.Orders.CustomerID. During the CI pipeline's schema comparison step, the deployment fails with a warning about potential data loss. What is the MOST appropriate way to handle this change safely in the project?
- A. Add a pre-deployment script that renames the column using sp_rename, and remove the column rename from the object definition file.✓ Correct
- B. Set the deployment option BlockOnPossibleDataLoss to False in the publish profile to suppress the warning.
- C. Delete the existing table definition and recreate the table with the new column name in the project.
- D. Use a post-deployment script to copy data from CustomerRef to CustomerID after the schema is applied.
Explanation
Column renames cannot be handled declaratively by a SQL Database Project because the deployment engine sees a dropped column (CustomerRef) and a new column (CustomerID) — it cannot infer a rename, leading to data loss. The correct approach is to use a pre-deployment script that executes sp_rename to rename the column before the declarative schema is compared, then keep the project definition aligned. Option B suppresses the warning but does not prevent actual data loss — the column will be dropped and recreated as empty. Option C deletes and recreates the table, causing data loss. Option D uses a post-deployment script to move data, but by that point the original column has already been dropped and the data is lost.