Search code examples
sql-servert-sqlsql-server-2016

Tsql: Issues with canceling long-running alter table?


Are there any negative issues with canceling a running alter table statement that alters a column from nvarchar(100) to nvarchar(25)? The table has at least 35M rows.

I'm asking because it's been running for the last 1.5 hours. This is the statement:

ALTER TABLE HourlyTable
ALTER COLUMN EmpId nvarchar(25);

We're using Microsoft SQL Server 2016 (SP2-GDR)


Solution

  • Internally, when executing an atler table alter column SQL recreates this column. When there is a high number of rows the process is very time consuming. When you cancel this type of operation in this scenario the rollback needs to be done.