Setting up a FileStream filegroup
In this recipe, we will add a Filestream Filegroup to our database.
Getting ready
Before you can use a FileStream Filegroup, the FileStream feature needs to be first enabled on your instance. If you haven't already enabled it, you can follow the Enabling Filestream recipe to enable it.
How to do it...
Let's take a look at the steps to create a FileStream Filegroup:
- Open the PowerShell ISE as an administrator.
- Import the
SQLPS
module and create a new SMO Server object as follows:#import SQL Server module Import-Module SQLPS –DisableNameChecking $instanceName = "localhost" $server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName
- Create a sample database for this recipe:
$databaseName = "FileStreamDB" #for this recipe only #drop if it exists if($server.Databases[$databaseName]) { $server.KillDatabase($databaseName) } #create the database $db = New-Object -TypeName Microsoft.SqlServer...