Basic Usage

Basic Usage #

Edit targets.hcl #

These are the servers we’ll be testing and applying configuration to. targets.hcl should already look like this:

target "localhost" {}
target "computer_name" {}
target "computer\instance" {}
target "fqdn.domain.tld" {}

This will use locahost for testing. The commented out targets are samples to connect to named instances and a fully.qualfied.server.tld. For each targt, sqldsc will try to connect to the name inside the quotes.

Review defaults.hcl #

These are the default settings that will be applied to the targets. It should look like this:

# The settings in defaults.hcl will be applied to all targets

# 50 is a reasonable default.  
# 49 is a value that should be different and demonstrate a change
resource "configuration" "cost_threshold" {
	name = "cost threshold for parallelism"
	value = 49
	ensure = "alter"

This is followed by a number of commented out settings.

Test the configuration #

Running sqldsc test will test the configuration against the targets.

sqldsc test

It will tell you if any changes need to be made.

This has been extensively tested from SQL Server 2014 through SQL Server 2019. SQL Server 2012 has recieved limited testing. SQL Server 2008 should work but has had limited testing.

Apply the configuration #

Running sqldsc apply will test the configuration against the targets and then apply the changes.

sqldsc apply

If any changes need to be made, there is a confirmation prompt. You can confirm by typing confirm. The apply command will always test all nodes before applying changes. It will only test and apply changes to servers where the user is in the sysadmin role.