Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6002583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:59:57+00:00 2026-05-23T00:59:57+00:00

suppose I have simple C# code to print HELLO WORLD as shown in here

  • 0

suppose I have simple C# code to print HELLO WORLD as shown in here

using System;
using System.Data;
using Microsoft.SqlServer.Server;
using System.Data.SqlTypes;

public class HelloWorldProc
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void HelloWorld()
    {
        SqlContext.Pipe.Send("HELLO WORLD!\n");
    }
}

So they say in that page:

This topic provides an overview of the
namespaces and libraries required to
compile database objects using the
Microsoft SQL Server integration with
the Microsoft .NET Framework common
language runtime (CLR). The topic also
shows you how to write, compile, and
run a simple CLR stored procedure
written in Microsoft Visual C#.

CLR integration functionality is
exposed in an assembly called
system.data.dll, which is part of the
.NET Framework. This assembly can be
found in the Global Assembly Cache
(GAC) as well as in the .NET Framework
directory. A reference to this
assembly is typically added
automatically by both command line
tools and Microsoft Visual Studio, so
there is no need to add it manually.

After create, (compiling it and add to path dll’s) you can use that code as a Stored Procedure like:

CREATE ASSEMBLY helloworld from 'c:\helloworld.dll' WITH PERMISSION_SET = SAFE

Once the assembly has been created, we can now access our HelloWorld method by using the create procedure statement. We will call our stored procedure “hello”:

CREATE PROCEDURE hello
AS
EXTERNAL NAME helloworld.HelloWorldProc.HelloWorld

Once the procedure has been created, it can be run just like a normal stored procedure written in Transact-SQL. Execute the following command:

EXEC hello

To drop that proc:

drop procedure hello

Once the procedure has been dropped, you can remove the assembly containing your sample code.

drop assembly helloworld

After this introduction:

I need to use a C++ code that also uses an extern dll, and my question is the following,

How could I use my C++ code (that also uses extern dll) inside that C# like in the example, so, after creating assembly at the moment I exec the stored proc, the following is transparant:

  1. SQL creates the assembly and then calls the C# code inside a dll.
  2. C# code calls C++ code (inside a dll)
  3. The C++ code calls extern dll.

So I only do

EXEC hello

and all that happens (SQL SERVER -> C# -> C++ -> extern dll).

  • How to make all this dll party go on and coexist, so I only execute a Stored proc in SQL Server like
    EXEC hello

I was thinking in

[DllImport("cCode.dll")]

but if the c++ code depends on an extern dll… I am getting lost

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:59:58+00:00Added an answer on May 23, 2026 at 12:59 am

    Well, if you’re going to go down this path, you might skip over using C# as a wrapper for your C++ dll (since it sounds like you’re just trying to use the SQL Server CLR integration as a means to call into a C++ routine).

    Instead, you could create and register a C++ COM+ Application (example) on the server and invoke this from SQL Server using sp_OACreate and related procedures. FYI: You could also create the COM+ Application in C# if you wanted, but it might be more work to interface with the C++ dll.

    I think you will have better luck with this approach because a COM+ Application can be configured to run in a dedicated server process instead of within the SQL Server process.

    Maybe your situation dictates otherwise, but as other people have commented, it’s best to leave this kind of “integration” outside of the database and put it into a separate application layer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple question. Is there a way ( using reflections I suppose
Suppose I have a simple XHTML document that uses a custom namespace for attributes:
I have a simple question that keeps me up all night :( . Suppose
Let's suppose I have a very simple Ruby program: require 'rubygems' require 'ruby-debug' x
I have some relatively simple code I have made that is supposed to retrieve
Suppose I have one html page with frames. The left frame is simply a
For example, suppose I have a batch file called 'test.cmd' and it simply contains:
Suppose you have 2 different ASP.NET applications in IIS. Also, you have some ASCX
Suppose I have a stringbuilder in C# that does this: StringBuilder sb = new
Suppose we have a table A: itemid mark 1 5 2 3 and table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.