Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By : Donabel Santos
Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By: Donabel Santos

Overview of this book

Table of Contents (21 chapters)
SQL Server 2014 with PowerShell v5 Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Adding full-text index


In this recipe, we will create a full-text index.

Getting ready

Before we proceed with this recipe, ensure that you have already created a full-text catalog in your instance. If you haven't created one, you can run the B04525 - Ch06 - 10 - Adding Full-Text Catalog - Prep.ps1 file that creates the sample database and full-text catalog and follow the Adding a full-text catalog recipe before proceeding with this recipe.

How to do it...

Let's take a look at the steps to create a full-text index:

  1. Open PowerShell ISE as an administrator.

  2. 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
  3. Add the following script and run it:

    #database
    $databaseName = "FullTextCatalogDB"
    $db = $server.Databases[$databaseName]
    
    #catalog
    $catalogName = "FTC"
    $catalog = $db.FullTextCatalogs...