How can I create a User Defined Function UDF In SQL Server, I was looking for an example, Could you provide a very simple example using C#?
1 Answer
It's not possible. SQL Server 2008 contains SQL CLR runtime that runs .NET languages.
3 Comments
edgarmtze
So I can only use Visual Basic, C#?. In other SQL version, like 2000, or 2005 Is it possible?
Axarydax
Do you need it? If it's a function, it might be called for lots of rows and lots of times, and this approach might be slow... And you might get memory leaks and crash SQL Server. If you absolutely must call unmanaged code (C,C++) from inside SQL Server, call the code via P/Invoke from the C#/VB.NET assembly. See this thread for more info: social.msdn.microsoft.com/Forums/en/sqlnetfx/thread/…
edgarmtze
I was planning to do an aggregate function, but for testing yield, i need to use a UDF.