Sql-server – Add column taking too long

sql serversql-server-2008

I'm trying to add a column to a database. The query has been running for 25mins and it's locking web access to the table and breaking our website:

alter table MyTable
add MyNewColumn varchar(max) not null
default ('')

The table contains binary data in a different column and is quite large.

Will cancelling by using the red "Cancel Executing Query" button cause additional problems? I'm just trying to figure out if I should attempt to cancel the query at this point, and what will happen since it's been running for so long.

Best Answer

The amount of time it takes to add a new column depends on the amount of data in your table. If you run sp_who2 active to see what the process id is you can kill the job. It will go into rollback, but will put the table back to the way that it was.

You should never try altering a table of a production system without knowing the how long the process will take.