I'm struggling to find much information on this subject so I'm wondering if any of you can enlighten me.
I basically have a mini application written in C# which accepts a string, performs a few manipulations to it and then returns the result. I now wish to create this function in SQLServer so that I can easily run it on records in my tables.
I know how to create and run SQLServer UDFs written in C# (ie. register the .dll in SQLServer before creating a function for it) but I don't seem to be able to get any output from my functions. For example if I have the following C# function...
using System;
using Microsoft.SqlServer.Server;
public static class MyClrUdfClass
{
[SqlFunction]
public static string HelloWorld(string myString)
{
return (myString);
}
}
And I run it in SQLServer like this...
USE [AdventureWorksDW2008R2]
GO
EXEC [dbo].HelloWorld'Hello World, this is my string!'
GO
The only output I get in SQLServer when I run the function is "Command completed successfully". So where is myString? I'm expecting that some SQL is needed to actually print the result but I'm not sure.
This probably has a very simple solution but as I mentioned earlier I'm really struggling to find any helpful information out there.
SELECT [dbo].HelloWorld 'Hello World, this is my string!