Showing posts with label article. Show all posts
Showing posts with label article. Show all posts

Monday, March 19, 2012

Extended Stored Procedure

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.
KK1.
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_extendedProcName (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(dllexport), 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(dllexport) ULONG __GetXpVersion()
{
return ODS_VERSION;
}

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

Note __declspec(dllexport) 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\Include 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.

Wednesday, February 15, 2012

Exporting SQL 2005 Maintenance Plans on SQL Cluster

I'm trying to export Microsoft SQL 2005 Maintenance plans per the following
article on the MSDN Forums:
http://forums.microsoft.com/MSDN/showpost.aspx?postid=389484&siteid=1
However I'm getting the following error:
TITLE: Microsoft SQL Server Management Studio
--
Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476
--
ADDITIONAL INFORMATION:
The SQL server specified in SSIS service configuration is not present or is
not available. This might occur when there is no default instance of SQL
Server on the computer. For more information, see the topic "Configuring the
Integration Services Service" in Server 2005 Books Online.
Login timeout expired
An error has occurred while establishing a connection to the server. When
connecting to SQL Server 2005, this failure may be caused by the fact that
under the default settings SQL Server does not allow remote connections.
Named Pipes Provider: Could not open a connection to SQL Server [2].
(MsDtsSrvr)
--
BUTTONS:
OK
--
Searching on google I found the following links which explain how to setup
SSIS as a clustered SQL service (which I did):
http://msdn2.microsoft.com/en-us/library/ms345193.aspx
I've also tried the steps outlined in:
http://msdn2.microsoft.com/en-us/library/aa337083.aspx
I'm at a loss... what am I doing wrong?
Thanks
BradI figured out my own problem. It turns out even though I made the registry
change mentioned in this article:
http://msdn2.microsoft.com/en-us/library/ms345193.aspx
The change I originally made didn't take effect - when I refreshed the
registry I noticed the key had reverted back to the original value.
Resetting the key and restarting the Integration Services cluster service
fixed the problem.
Thanks!
Brad
"Brad Baker" <brad@.nospam.nospam> wrote in message
news:u7RdSS16GHA.4404@.TK2MSFTNGP04.phx.gbl...
> I'm trying to export Microsoft SQL 2005 Maintenance plans per the
> following article on the MSDN Forums:
> http://forums.microsoft.com/MSDN/showpost.aspx?postid=389484&siteid=1
> However I'm getting the following error:
> TITLE: Microsoft SQL Server Management Studio
> --
> Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum)
> For help, click:
> http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476
> --
> ADDITIONAL INFORMATION:
> The SQL server specified in SSIS service configuration is not present or
> is not available. This might occur when there is no default instance of
> SQL Server on the computer. For more information, see the topic
> "Configuring the Integration Services Service" in Server 2005 Books
> Online.
> Login timeout expired
> An error has occurred while establishing a connection to the server. When
> connecting to SQL Server 2005, this failure may be caused by the fact that
> under the default settings SQL Server does not allow remote connections.
> Named Pipes Provider: Could not open a connection to SQL Server [2].
> (MsDtsSrvr)
> --
> BUTTONS:
> OK
> --
> Searching on google I found the following links which explain how to setup
> SSIS as a clustered SQL service (which I did):
> http://msdn2.microsoft.com/en-us/library/ms345193.aspx
> I've also tried the steps outlined in:
> http://msdn2.microsoft.com/en-us/library/aa337083.aspx
> I'm at a loss... what am I doing wrong?
> Thanks
> Brad
>|||Hi,
Thank you for your reply and the detailed additional feedback on how you
were successful in resolving this issue. This information has been added to
Microsoft's database. Your solution will benefit many other users, and we
really value having you as a Microsoft customer.
If you have any other questions or concerns, please do not hesitate to
contact us. It is always our pleasure to be of assistance.
Have a nice day!
Charles Wang
Microsoft Online Community Support
======================================================When responding to posts, please "Reply to Group" via
your newsreader so that others may learn and benefit
from this issue.
======================================================This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================