none
Creating DLL file for Extended Stored procedure in C#

    Question

  • Hi All,

     

    Is there any way that I can create a dll file for Extended stored procedure(SQL server) in C# ?

     

    I an able to create that in VC++. in VC++ there is DLLMain which serve as entry point and a paramter can be passed to it using Extended stored procedure. But since C# does not have any such entry point. Hence is there any way that I can achieve this?

     

    Any pointers to this will be highly appreciated.

     

    Thanks

    Sid

    Friday, August 10, 2007 11:51 PM

Answers

  • If you use SQL Server 2005 then you can use the .NET CLR inside your SQL Server.

    If you use SQL Server 2000 still you have to use the COM dlls.

     

    In SQL Server 2005 you need not to have the Extended SPs, the CLR integration helps you to overcome this issue, the deployment and maintaining the CLR assemblies are much better than the legacy COM dlls.

     

    If you use SQL Server 2005, use the .NET CLR integration...

    Saturday, August 11, 2007 3:46 PM
  • An extended stored procedure (xp) is a C or C++ dll which is registered with SQL Server, and you cannot write an xp using C#. Xp's are being deprecated in SQL Server in favor of .NET assemblies as you can, in SQL Server 2005, write a .NET Framework (CLR) dll (with C#/VB.NET/etc) and register that assembly in SQL Server:
    1. You write and compile your .NET dll
    2. You register the dll with SQL Server (use CREATE ASSEMBLY syntax)
    3. Create T-SQL wrapper objects (stored procs/triggers/functions) around the methods in your assembly that you want exposed.
    4.Execute and be happy!!

    Visual Studio 2005 Pro and above has a new project type; SQL Server Project, which helps you with steps 2 and 3, so you don't have to manully register your assembly and manually create the wrapper methods.

    Niels
    Wednesday, October 24, 2007 11:18 AM

All replies

  • No you can not write an xp in C#, but why not write a SQLCLR method in C# instead and upload that dl to SQL Server? Look for .NET programming in BOL to get more about what you can do.

    Niels
    Saturday, August 11, 2007 6:22 AM
  • If you use SQL Server 2005 then you can use the .NET CLR inside your SQL Server.

    If you use SQL Server 2000 still you have to use the COM dlls.

     

    In SQL Server 2005 you need not to have the Extended SPs, the CLR integration helps you to overcome this issue, the deployment and maintaining the CLR assemblies are much better than the legacy COM dlls.

     

    If you use SQL Server 2005, use the .NET CLR integration...

    Saturday, August 11, 2007 3:46 PM
  •  

    Thanks manivannan,

    Your comments helps. I finally ended up using VC++.NET to create the DLL for extended stored procedure.

    Tuesday, August 21, 2007 9:54 PM
  • Hi,

     

    Can anyone tell me how to write extended stored procedures in C# ?

     

    Thanks

    Kulvinder Singh

     

    Wednesday, October 24, 2007 9:32 AM
  • An extended stored procedure (xp) is a C or C++ dll which is registered with SQL Server, and you cannot write an xp using C#. Xp's are being deprecated in SQL Server in favor of .NET assemblies as you can, in SQL Server 2005, write a .NET Framework (CLR) dll (with C#/VB.NET/etc) and register that assembly in SQL Server:
    1. You write and compile your .NET dll
    2. You register the dll with SQL Server (use CREATE ASSEMBLY syntax)
    3. Create T-SQL wrapper objects (stored procs/triggers/functions) around the methods in your assembly that you want exposed.
    4.Execute and be happy!!

    Visual Studio 2005 Pro and above has a new project type; SQL Server Project, which helps you with steps 2 and 3, so you don't have to manully register your assembly and manually create the wrapper methods.

    Niels
    Wednesday, October 24, 2007 11:18 AM
  • Thanks for the reply.

     

    Can you link me to a few good tutorials on this ?

     

    Thanks

    Kulvinder Singh

     

    Wednesday, October 24, 2007 12:49 PM
  • Complete Steps For CLR Integration 

    http://acron.wordpress.com/

    Pankaj
    • Proposed as answer by Pankaj Mathur Friday, December 25, 2009 7:05 PM
    Friday, December 25, 2009 7:02 PM