473,750 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extended Stored Procedure

1 New Member
Hi all,
I'd like some advice on adding an extended stored procedure (XP). I found an article which advises "put the call of the extended prodecure within a database procedure in the database from which it will be called".
http://www.windowsitlibrary.com/Content/77/20/1.html#1
This sounds like what I want to do, where can I find details on "how to" do this, including granting rights to execute the SP, XP?
Running Windows 2000 Server, MS SQL Server 2000.

All comments appreciated.
KK
Jan 11 '07 #1
1 4437
iburyak
1,017 Recognized Expert Top Contributor
1.
http://www.codeproject .com/database/extended_sp.asp

2.
Creating Extended Stored Procedures
An extended stored procedure is a function with a prototype:

SRVRETCODE xp_extendedProc Name (SRVPROC *);

Using the prefix "xp_" is optional. Extended stored procedure names are case sensitive when referenced in Transact-SQL statements, regardless of code page/sort order installed on the server. An extended stored procedure is implemented in a 32-bit dynamic-linked library (DLL). When you build a DLL:

If an entry point is necessary, write a DllMain function.
This function is optional; if you do not provide it in source code, the compiler links its own version, which does nothing but return TRUE. If you provide a DllMain function, the operating system calls this function when a thread or process attaches to or detaches from the DLL.

All functions called from outside the DLL (all extended stored procedure functions) must be exported.
You can export a function by listing its name in the EXPORTS section of a .def file, or you can prefix the function name in the source code with __declspec(dlle xport), a Microsoft compiler extension (Note that __declspec() begins with two underscores).

These Open Data Services files are required for creating an extended stored procedure DLL.

File Description
Srv.h Open Data Services header file
Opends60.lib Import library for Opends60.dll


It is highly recommended that all Microsoft® SQL Server™ 2000 extended stored procedure DLLs implement and export the following function:

__declspec(dlle xport) ULONG __GetXpVersion( )
{
return ODS_VERSION;
}

When SQL Server loads an extended stored procedure DLL, SQL Server checks for the above function.



Note __declspec(dlle xport) is a Microsoft-specific compiler extension. If your compiler does not support this directive, you should export this function in your DEF file under the EXPORTS section.


When SQL Server is started with the trace flag -T260 or if a user with system administrator privileges runs DBCC TRACEON (260), then if the extended stored procedure DLL does not support __GetXpVersion( ), a warning message (Error 8131: Extended stored procedure DLL '%' does not export __GetXpVersion( ).) is printed to the error log (Note that __GetXpVersion( ) begins with two underscores). If you get this message, and you are running an extended stored procedure DLL compiled with headers and libraries from SQL Server version 6.x, refer to Level 1: Handling Discontinued Functionality. If you get this message and are running an extended stored procedure DLL compiled with headers and libraries from SQL Server 7.0, your extended stored procedure DLL is not exporting the function __GetXpVersion( ).

If the extended stored procedure DLL exports __GetXpVersion( ), but the version returned by the function is less than that required by the server, a warning message (Error 8132: Extended stored procedure DLL '%' reports its version is %d.%d. Server expects version %d.%d.) stating the version returned by the function and the version expected by the server is printed to the error log. If you get this message, you are returning an incorrect value from __GetXpVersion( ), or you are compiling with an older version of srv.h.



Note SetErrorMode, a Microsoft Win32® function, should not be called in extended stored procedures.


For more information about creating a DLL, see the development environment documentation and the Microsoft Win32 SDK documentation.

To create an extended stored procedure DLL by using Microsoft Visual C++

1. Create a new project of type Win32 Dynamic Link Library.


2. Set the directory for include files and library files to C:\Program Files\Microsoft SQL Server\80\Tools \DevTools\Inclu de and C:\Program Files\Microsoft SQL Server\80\Tools \DevTools\Lib, respectively.
On the Tools menu, click Options.


In the Options dialog box, click the Directories tab and set the directory for include files and library files.
On the Project menu, click Settings.


In the Project Settings dialog box, click the Link tab. Click the General category, and then add opends60.lib to object/library modules.


Add source files (.c, .cpp, and .rc files, and so on) to your project.


Compile and link your project.
Jan 11 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3942
by: Matik | last post by:
Hi, I alredy tried to search this problem in last posts, but I couldn't find the answer. I try to access via Extended SP the method in a dll. I registered the dll as a ExSP, with a name of method. But after calling it in T-SQL, I became such a error message:
3
2386
by: Bruce | last post by:
Since DBlib is no longer the suggested method for connecting back to sql server from an Extended Stored Procedure, has anyone built any extended stored procedures that use other connection methods like OLEDB? Has anyone seen links to any sample extended stored procedures that use something other than db-lib? In particular I am interested in something that connects back to the database as the user who invoked the extended stored...
1
1753
by: smauldin | last post by:
What is the overhead of using extended stored procedures? I created a table with 500,000 rows. 1) I ran a select on two columns and it runs in about 5 seconds. 2) I ran a select on one column and called an UDF (it returns a constant string) and it takes 10 seconds. 3) I ran a select on one column and called a UDF that calls an extended stored procedure that returns a string and it takes 65 seconds. I also tried running test 3 with 4...
1
5611
by: scanner2001 | last post by:
Here is what I would like to be able to do, Have an SQL extended stored procedure to do file copy, delete, and rename(move) procedures. I have written the code in C# to do this, in the form of a simple app, and it contains all of the functionality, error handling, etc. that I need. I would like to use the extended stored procedure framework from visual studio, but I am unsure how to merge these two together. I do "not" want to make a dll,...
0
1138
by: scanner2001 | last post by:
I am writing an extended stored procedure in c++ 7. As I have been testing, I am able to run this on my local box, my local sql server. When I register the extended stored procedure on a different test sql server, and try to run it, I get the following error: ODBC: Msg 0, Level 16, State 1 Cannot load the DLL xp_test.DLL, or one of the DLLs it references. Reason: 126(The specified module could not be found.). Both systems are very close...
0
9001
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9396
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9342
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8263
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2226
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.