Readme_Assembly Cleanup Sample
This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005.
The AssemblyCleanup sample contains a .NET Stored Procedure, written in Visual C#, that cleans-up unused assemblies in the current database by querying the metadata catalogs.
Its only parameter, visible_assemblies, is used to specify whether unused visible assemblies should be dropped or not. A value of 'false' means by default only unused invisible assemblies will be dropped, otherwise all unused assemblies will be dropped.
The set of unused assemblies are those assemblies that do not have any entry points defined (routines / types and aggregates) and there are no used assemblies referencing them directly or indirectly.
|When you compile SQLCLR samples, the path of the version of the Microsoft .NET Framework compiler that was distributed with SQL Server must be the first Framework directory in the PATH environment variable. The location of the compiler that is included with SQL Server will be either drive:\WINNT\Microsoft.NET\Framework\v2.0.xxxxx or drive:\Windows\Microsoft.NET\Framework\v2.0.xxxxx, where drive is the installation drive and xxxxx is the version number of the .NET Framework that was included with SQL Server.|
The default installation directory is C:\Program Files\Microsoft SQL Server\100\Samples\Engine\Programmability\CLR\AssemblyCleanup.
SQL Server samples and sample databases must be downloaded and installed before you can view or work with them. For more information, see Considerations for Installing SQL Server Samples and Sample Databases.
If you have not already created the strong-name key file ExternalSampleKey.snk, generate the key file using the following instructions.
Open a Microsoft Visual Studio 2005 command prompt. Click Start, point to All Programs, point to Microsoft Visual Studio 2005, point to Visual Studio Tools, and then click Visual Studio 2005 Command Prompt.
Open a Microsoft .NET Framework command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.
At the command prompt, use the change directory (CD) command to change the current folder of the command prompt window to the Samples folder.
Note: To determine the folder where samples are located, click Start, point to All Programs, point to Microsoft SQL Server, point to Documentation and Tutorials, and then click Samples Directory. If the default installation location was used, the samples are located in <system_drive>:\Program Files\Microsoft SQL Server\100\Samples.
At the command prompt, run the following command to generate the key file:
sn -k ExternalSampleKey.snk
Important: For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.
To build the sample, do the following:
Compile the sample by using the provided Microsoft Visual Studio solutions or by using a command similar to the following at the command prompt:
Sn -k keypair.snk
Csc /reference:"C:\Program Files\Microsoft SQL Server\MSSQL.10.MSSQLSERVER\MSSQL\Binn\sqlaccess.dll" /target:library /debug /out:CS\AssemblyCleanup\Bin\Debug\AssemblyCleanup.dll CS\AssemblyCleanup\*.cs
Make sure that the AdventureWorks database is installed, or create the database in which you want to install the samples.
Load the Transact-SQL script in Scripts\installCS.sql or Scripts\installVB.sql into Management Studio and execute it. This file contains script to install and register the sample CLR objects into SQL Server.
To run the sample, do the following:
To remove the sample, do the following:
The CLR for SQL Server or SQL Server Express must be enabled for this sample to work correctly.
Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications and assemblies should not be connected to or used with your production SQL Server database or your report server without the permission of the system administrator.