In this recipe, we will extract user-defined assemblies and resave these back to the filesystem as DLLs.
We can use the SampleDB
database that we used in the previous recipe, or you can substitute this with any database that is accessible to you that has some user-defined assemblies.
These are the steps to extract user-defined assemblies:
Open the PowerShell console application by going to Start | Accessories | Windows PowerShell | Windows PowerShell ISE.
Import the SQLPS module as follows:
#import SQL Server module Import-Module SQLPS -DisableNameChecking
First, we will create a
bcp
format file. Add the following script and run:$VerbosePreference = "Continue" $instanceName = "KERRIGAN" $timestamp = Get-Date -Format "yyyy-MMM-dd-hhmmtt" $emptyBLOB_tableName = "SampleDB.dbo.EmptyBLOB" $formatFileName = "C:\CLR Files\clr$($timestamp).fmt" $fmtcmd = "bcp `"$emptyBLOB_tableName`" format nul -T -N -f `"$formatFileName`" -S $instanceName...