How to call a SQL function in SQL server from C#?

  • Thread starter Thread starter Andy Li
  • Start date Start date
A

Andy Li

I know how to call a stored procedure in SQL server from C# using SQLCommand
class. Could someone tell me how to call a SQL function in SQL sever from
C#?

Thanks,

Andy
 
Andy,

You can call a function just like a stored procedure. However, I
believe that for the name, you can not use just the function name, but
rather, you have to use the function name prefixed by the database name.

Hope this helps.
 
Hi Nicholas,

At least from the Query Analizer you need to prefixe the function with the
owner of it.
I have never called a function from a .NET app. but I would try it like
this if not work then prefixed completly beggining with the DB name like:
dbname.dbo.functionName


Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Nicholas Paldino said:
Andy,

You can call a function just like a stored procedure. However, I
believe that for the name, you can not use just the function name, but
rather, you have to use the function name prefixed by the database name.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Andy Li said:
I know how to call a stored procedure in SQL server from C# using SQLCommand
class. Could someone tell me how to call a SQL function in SQL sever from
C#?

Thanks,

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top