Re: Loading an external DLL

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Carsten Ingemansson (carsten_at_trivector.se)
Date: 10/07/04


Date: Thu, 7 Oct 2004 14:49:40 +0200

To answer my own question...

Create a DLL
Export a function - "MyFunc"
Put the DLL i SQL Servers BINN directory

Execute the following in Query analyzer to register the function i SQL
Server
    use master
    go
    sp_addextendedproc 'MyFunc', 'MyDLL.dll'
    go

Call the function from Query Analyzer or from a trigger
exec master..MyFunc 'Param1', 'Param2', ...

To unregister the function, execute the following
    use master
    go
    sp_dropextendedproc 'MyFunc'
    go

The following command could be useful if SQL Server doesn't release the DLL.
If SQL Server still doesn't release the DLL you have to restart SQL Server.
    use master
    go
    DBCC MyDLL(Free)
    go

Carsten

"Carsten Ingemansson" <carsten@trivector.se> skrev i meddelandet
news:OgDYpCiqEHA.4008@TK2MSFTNGP14.phx.gbl...
> Is it possible to load, run a function from and then unload an external
DLL
> from within a trigger. If it is - how do I do it?
>
> Carsten
>
>



Relevant Pages

  • Where the !@?!@ is my Stored Procedure?
    ... I wrote the following in the SQL Server 2005 Express Management Studio ... and hit execute. ... Even though Query Analyzer indicated success when I ... to execute the code again, and lo and behold, SQL Server gives me the ...
    (comp.databases.ms-sqlserver)
  • Re: SQL 2K5 Custom Resolver (Business Logic Handler)
    ... Looking for a SQL Server replication book? ... register the dll in order to get the resolver to work. ... The Custom Resolver Component for article 'job' does not have a valid ...
    (microsoft.public.sqlserver.replication)
  • Re: Error 22272: Cannot load the DLL xpstar.dll...
    ... I would look for MSVCR71.DLL in SYSTEM32. ... I believe that if an entire DLL was missing, ... Reinstall the SQL Server tools? ...
    (comp.databases.ms-sqlserver)
  • Re: getting process info for processes started by the Service Control Manager
    ... > I have written an extended stored procedure that need to know ... > GetStartupInfo when the dll was loaded by the parent process (SQL Server). ... The problem arises when the SQL Server instance is started ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Different version of SQL Server returns different Result
    ... > I have a stored procedure that is created and located at SQL Server 6.5. ... When the stored procedure's result is invalid, it will return NULL, else it ... > The problem is, when I tried to execute it at Query Analyzer for SQL 2000, ...
    (microsoft.public.sqlserver.programming)