问题
I am trying to suppress parallelism in SQL Server while altering a table to add a column with the option maxdop=1
. However I get an error in the syntax. I tried several ways but I can make it work, does anybody know how to use this option when adding a column?
ALTER TABLE [dbo].[mytable]
ADD neColumn varchar(max)
WITH (MAXDOP = 1);

回答1:
Pretty sure you can't use query hint for an alter table.
See list at https://msdn.microsoft.com/en-us/library/ms181714.aspx
Depending on what you want to do, you may want to set the server parallelism to 1 before you run your query and set it back to its initial value once you are done.
check https://msdn.microsoft.com/en-us/library/ms189094.aspx to do so.
来源:https://stackoverflow.com/questions/37023344/sql-server-alter-table-add-column-maxdop-1