< Back

Set-DbaMaxDop

Mon Jan 13, 2020 5:39 pm

NAME Set-DbaMaxDop



SYNOPSIS

Sets SQL Server maximum degree of parallelism (Max DOP), then displays information relating to SQL Server Max DOP

configuration settings. Works on SQL Server 2005 and higher.





SYNTAX

Set-DbaMaxDop [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-SqlCredential]

<Pscredential>] [[-Database] <System.Object[]>] [[-ExcludeDatabase] <System.Object[]>] [[-MaxDop] <Int>]

[[-InputObject] <Psobject>] [-AllDatabases <Switch>] [-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

Uses the Test-DbaMaxDop command to get the recommended value if -MaxDop parameter is not specified.



These are just general recommendations for SQL Server and are a good starting point for setting the "max degree of

parallelism" option.



You can set MaxDop database scoped configurations if the server is version 2016 or higher





PARAMETERS

-AllDatabases [<Switch>]

If this switch is enabled, Max DOP will be set on all databases. This switch is only useful on SQL Server 2016

and higher.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Database [<System.Object[]>]

Specifies one or more databases to process. Options for this list are auto-populated from the server. If

unspecified, all databases will be processed.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.

This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables

advanced scripting.

Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own

try/catch.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ExcludeDatabase [<System.Object[]>]

Specifies one or more databases to exclude from processing. Options for this list are auto-populated from the

server



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-InputObject [<Psobject>]

If Test-SqlMaxDop has been executed prior to this function, the results may be passed in via this parameter.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-MaxDop [<Int>]

Specifies the Max DOP value to set.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).



Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -

Integrated are all supported.



For MFA support, please use Connect-DbaInstance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The target SQL Server instance or instances. Defaults to localhost.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: MaxDop, SpConfigure

Author: Claudio Silva (@claudioessilva)



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Set-DbaMaxDop -SqlInstance sql2008, sql2012



Sets Max DOP to the recommended value for servers sql2008 and sql2012.

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Set-DbaMaxDop -SqlInstance sql2014 -MaxDop 4



Sets Max DOP to 4 for server sql2014.

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Test-DbaMaxDop -SqlInstance sql2008 | Set-DbaMaxDop



Gets the recommended Max DOP from Test-DbaMaxDop and applies it to to sql2008.

-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Set-DbaMaxDop -SqlInstance sql2016 -Database db1



Set recommended Max DOP for database db1 on server sql2016.

-------------------------- EXAMPLE 5 --------------------------



PS C:\\>Set-DbaMaxDop -SqlInstance sql2016 -AllDatabases



Set recommended Max DOP for all databases on server sql2016.



RELATED LINKS

https://dbatools.io/Set-DbaMaxDop