我试图在SQL server 2008中调用我的第一个CLR存储过程。我已经成功编译了DLL并创建了程序集。现在我正在尝试Create the stored procedure that references the registered assembly by using the CREATE PROCEDURE statement.关注this tutorial,我收到了语法错误...
--This line worked. Just including this code just to show what I am doing ...
--create assembly
--LevenshteinLibrary
--from 'Drive Letter:\Path\LevenshteinLibrary.dll'
create procedure testCLR(@s1 nvarchar(1000), @s2 nvarchar(1000))
as external LevenshteinLibrary.getLevenshteinDistance --Incorrect syntax near '.'.
我应该怎么做才能创建此程序?我没有在msdn create procedure页面上看到任何解释“as external。”的正确语法的内容。
VB.net代码如下所示:
Imports System.Math
Imports System.Text.RegularExpressions
Imports Microsoft.SqlServer.Server
Partial Public Class LevenshteinerAndSoundexer
<SqlProcedure()> _
Public Shared Function getLevenshteinDistance(ByVal string1 As String, ByVal String2 As String) As Integer
答案 0 :(得分:3)
这对你有用吗?
create procedure testCLR(@s1 nvarchar(1000), @s2 nvarchar(1000))
as external NAME LevenshteinLibrary.LevenshteinerAndSoundexer.getLevenshteinDistance
As External
的文档有三个部分名称,您只有两个部分。
此外,正如Pondlife指出的那样,As External
也需要NAME
。
通常,班级是一个“部分”班级,我不确定你的班级是什么样的。我认为您可能还需要在VB方法前添加一个属性,如下所示:
Partial Public Class LevenshteinerAndSoundexer
<SqlProcedure()> _
Public Shared Function getLevenshteinDistance(ByVal string1 As String, ByVal String2 As String) As Integer
您可能希望查看本文并按照他们在那里描述的过程进行操作:http://msdn.microsoft.com/en-us/library/5czye81z(v=vs.80).aspx