C# clr 存储过程例子(完整从:编译到配置到存储过程的安装部署到使用)
//代码
using System;
using System.Data;
using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;
public class HelloWorldProc
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void HelloWorld()
{
SqlContext.Pipe.Send("Hello world!/n");
}
}
//编译
csc /target:library helloworld.cs
//建立部署
CREATE ASSEMBLY helloworld from 'D:/StoreProcedure/helloworld.dll' WITH PERMISSION_SET = SAFE
CREATE PROCEDURE hello
AS
EXTERNAL NAME helloworld.HelloWorldProc.test
//权限配置
EXEC sp_configure 'clr enabled', '1';
RECONFIGURE;
//使用
exec hello
本文介绍了一个简单的C# CLR存储过程示例,包括代码实现、编译步骤、SQL Server中CLR存储过程的部署及配置方法,并演示了如何调用执行该存储过程。
4343

被折叠的 条评论
为什么被折叠?



