Creating a new assembly

In this recipe, we will create a new user-defined assembly.

Getting ready

Create a folder named C:\CLR Files and copy the QueryWorksCLR.dll file that comes with the book's sample files to this folder.

We will load this to the SampleDB database. Feel free to use a database accessible to you; just ensure that you replace the database name in the script.

How to do it...

These are the steps required to create a new assembly in SQL Server:

  1. Open PowerShell ISE as an administrator.
  2. Import the SQLPS module as follows:
    #import SQL Server module
    Import-Module SQLPS -DisableNameChecking
  3. Add the following script and run it:
    $instanceName = "localhost" $databaseName = "SampleDB" $assemblyName = "QueryWorksCLR" $assemblyFile = "C:\CLR Files\QueryWorksCLR.dll" ...

Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.