Friday, February 24, 2012

How to use C# DLL in Extended Stored Procedure?

Hello,

i have created one C# DLL

xp_hello.dll

Its having below code in Class1.cs

namespace xp_hello

{

public class Class1

{

public string xp_hello()

{

string strReturn = string.Empty;

strReturn = "Chirag Patel";

return strReturn;

}

}

}

i compiled that DLL and kept it in C drive.

now i am trying to create Extended stored procedure using

sp_addextendedproc 'xp_hello', 'c:\xp_hello.dll'

its showing successful creation.

Now i am trying to Execute it with

DECLARE @.txt varchar(33)

EXEC xp_hello @.txt OUTPUT

now its showing below message.

Msg 17751, Level 16, State 0, Procedure xp_hello, Line 1

Could not find the function xp_hello in the library xp_hello.dll. Reason: 127(The specified procedure could not be found.).

can anyone please help me out in this?

Thanks

Extended stored procedures are C++ coded. If you want to use the CLR you will have to use the SQL CLR project / the CLR integration in SQL Server. (which is available in SQL Server 2005)

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Hello Jens,

Thanks a lot.

its done. i able to call C# DLL from Stored Proc.

Great,

Thanks.

No comments:

Post a Comment