Help Center> Relational Database Service> Best Practices> RDS for SQL Server> Installing a C# CLR Assembly in RDS for SQL Server
Updated on 2022-12-07 GMT+08:00

Installing a C# CLR Assembly in RDS for SQL Server

Microsoft SQL Server provides assemblies to make database operations simple and convenient.

When you restore data to a new or an existing DB instance, the clr enabled parameter is disabled by default. To use the CLR integration function, you need to enable clr enabled first. For details about how to enable the CLR integration function, see Enabling CLR Integration.

Procedure

  1. Create a C# function to compile an SQL Server DLL.

    Figure 1 C# function code

    For more information about user-defined functions, see CLR User-Defined Functions.

  2. Use SQL Server Management Studio to connect to the database.

    Figure 2 Connecting to the server

  3. Select the target database and create the corresponding assembly.

    • Only the SAFE assembly (Permission set is Safe) can be created.
    • The DLL file is saved in the hexadecimal format, as shown in Figure 4.
    Figure 3 Creating an assembly
    Figure 4 DLL file

  4. Execute the program. If the execution result is shown as Figure 5, the execution is successful. The TESTS assembly is added, as shown in Figure 6.

    Figure 5 Execution result
    Figure 6 TESTS assembly