Set autoclose property for all database


in SSMS , Right click on database node in Object Explorer, Select menu item “Start PowerShell”

Type in following in power shell window to set Auto Close on all databases

dir | foreach {$_.AutoClose = $true; $_.Alter()}

If you would prefer to set on specific database that starts with name “DB”

dir | where-object {$_.Name.StartsWith("DB")} | foreach {$_.AutoClose = $true; $_.Alter()}

Related forum thread: http://social.msdn.microsoft.com/Forums/en-US/sqltools/thread/c2780156-7a6f-4b29-a2f6-f4bfa682379c/#0c0c375b-e584-4c3f-9d40-482ca1a15999

Advertisements

Developer @ SQL Server Team, Microsoft

Posted in DB Management, SQL Power shell, SQL Server, SSMS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: