Groups | Blog | Home
all groups > sql server (alternate) > july 2004 >

sql server (alternate) : Passing Parameters to Extended Stored Procedures


chelseagraylin NO[at]SPAM hotmail.com
7/20/2004 1:09:12 PM
I'm trying to pass parameters to an extended stored procedure, to no
avail. I would like to pass two integers to the dll and I have the
following three snippets:

1. The C++ portion of the dll:
....
declspec(dllexport) int myAddNumbers(int m, int n)
....

2. The creation of the extended stored procedure:
EXEC sp_addextendedproc myAddNumbers , 'foodll.dll';

3. The usage:
create function TestFunction()
returns integer
as
begin
declare @rc integer
exec @rc = myAddNumbers
return (@rc)
end

How do any of the above three things need to be modified in order to
make this work?

Erland Sommarskog
7/20/2004 10:02:09 PM
[posted and mailed, please reply in news]

CG (chelseagraylin@hotmail.com) writes:
[quoted text, click to view]

Obviously you must pass the parameters in the EXEC statement:

EXEC @rc myAddNumbers @int1, @int2

But then you need to retrieve the values in the XP as well. That's a
a little more tricky I guess. No, I am not going to tell you how.
Instead, if you have not done so, install the samples that come with
SQL Server. Then in
C:\Program Files\Microsoft SQL Server\80\Tools\DevTools\Samples\ods\xp_param
you find a sample, which I believe will take you a long way.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
AddThis Social Bookmark Button