Developing and Deploying SQL Sever Apps on Windows Integrity
35 of 39
The example below from an Integrity Server shows how to create a .NET assembly using a 64-
bit SDK environment and deploying to the SQL Server 2005
1. From the taskbar, click Start, point to All Programs, point to Microsoft .NET Frame
works SDK v2.0(64 bit), select SDK Command Prompt.
2. Create a project folder underneath and run the following command to create the safe
key for the .NET code to execute.
Sn –k keypair.snk
3. Copy the HelloWorld project created in Section 3.2 c# stored procedure to the project
folder or see the Microsoft website for more samples
.
4. Compile the sample HelloWorld.sln c# project.
Msbuild /nologo /verbository:quiet /property:Configuration=Debug CS\ HelloWorld.sln
Note: Instead of Steps 3 and 4 above, you could write your stored procedure in c#
using a text editor (e.g., Notepad) and name it HelloWorld.cs. You could use
the same source code from Section 3.2 c# stored procedure. However, you
must ensure that the proper calling sequences are inserted. Sample code is
shown below:
public class Hello1
{
public static void Main()
{
System.Console.WriteLine("Hello, World!");
}
}
5. Compile the code by using the csc.exe compiler. For VB .NET code use vbc.exe
instead. See more details about command line building of c# code at the Microsoft
website.
csc.exe HelloWorld.cs
6. This procedure generates a .dll which you can use as a stored procedure as follows.
During the ClickOnce install in Section 3.2, SQL server used the similar procedure
internally.
CREATE ASSEMBLY HelloWorld
FROM
'C:\Program Files\Microsoft.NET\SDK\v2.0 64bit\projects\HW\HelloWorld.exe'
WITH permission_set = Safe;
GO
CREATE PROCEDURE usp_HelloWorld
AS ExTERNAL NAME HelloWorld