Calling sql server user defined function from C#

  • Thread starter Thread starter Lalit Bhatia
  • Start date Start date
Lalit said:
How can we call a sql server user defined function from C#?

Create a SqlCommand and set the commandtext to

@"select userDefinedFunction(@param, @param)"

Now add these parameters to the SqlCommand aswell and you're all set.

Alternatively you could wrap the UDP in a stored procedure and call that
instead.

Jesse Houwing
 
Hi,

IIRC you need to include the owner of the function:

@"select dbo.userDefinedFunction(@param, @param)"
 
Back
Top