Skip to content
Advertisement

Calling SQL Defined function in C#

I have written this scalar function in TSQL:

I want to call this function in my C# code. Here’s what I have so far:

Advertisement

Answer

You can’t just call the function name, you will need to write an inline SQL statement which makes use of the UDF:

And remove the CommandType, this isn’t a Stored Procedure, its a User Defined Function.

In all:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement