You must Sign In to post a response.
  • Category: .NET

    How to call c# or Javascript function in SQl Server

    Hello Sir/Madam

    Can you please suggest , is there any way to call a javascript or C# function call in Sql Server .

    Thanks,
    Bhavik Shah
  • #766096
    Hi,
    You can call C# functions from SQL Server Stored Procedure with the help of CLR(Common Language Runtime) SP.
    Please refer this URL:
    http://blog.sqlauthority.com/2008/10/19/sql-server-introduction-to-clr-simple-example-of-clr-stored-procedure/

  • #766115
    SQL Server 2005 supports CLR so it means we can use CLR in backend so how to do that. let's see.
    Yes, it is possible to use .NET in a SQL Server 2005 database. and .Net framework 2.0 and above.
    MSDN says,
    Create a SQL user-defined function by adding a User-Defined Function to a SQL Server project. After successful deployment, the user-defined function can be called and executed.
    see below links
    http://stackoverflow.com/questions/4002382/how-to-call-c-sharp-function-in-stored-procedure
    https://msdn.microsoft.com/en-us/library/w2kae45k(v=vs.90).aspx
    http://blog.sqlauthority.com/2008/10/19/sql-server-introduction-to-clr-simple-example-of-clr-stored-procedure/

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #766140
    1. For do this you have to create "SQL Server Project"
    2. You have to use [Microsoft.SqlServer.Server.SqlProcedure] for methods.
    3. You can run the C# project directly in the your query analyser.
    EXEC <SQL Project>

    By Nathan
    Direction is important than speed


  • Sign In to post your comments