1

Suposse I have an UDF in SQL Server 2008:

Create function dbo.ReadXml (@xmlMatrix xml) returns table
as
return
( select
   --SOME C++ CODE
)
go
  • Is it possible to add a c++ code or call a c++ function inside the UDF?

1 Answer 1

2

Onyl if this C++ function was compiled and installed as an extended stored procedure.
But extended stored procedures are deprecated and will be removed soon.

So your only reliable option is to write a CLR function. It can be a C# CLR function that calls an external C++ dll, or it might be a managed C++ CLR function that would contain your code directly.

Sign up to request clarification or add additional context in comments.

4 Comments

Ok, so the steps would be: - To have a C# CLR function - This C# function calls external C++ dll.... How would that C# call a C++ dll? I don't undestand well that step...
@cMinor By using the DllImportAttribute.
As you answered, What do you recommend, C# CLR Function, or managed C++ Function?
@cMinor Whatever is easier for you to use/maintain. For me it would be easier to have a separate C++ dll, as I'm way too unfamiliar with managed C++. However, having a single managed C++ assembly has an advantage of requiring the lowest permissions (SAFE) because you don't try to load something from outside.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.