Timeline for Function vs. Stored Procedure in SQL Server
Current License: CC BY-SA 2.5
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 7, 2022 at 19:30 | comment | added | DavidRR |
A user-defined function can be called via the EXECUTE statement. See Microsoft's article Execute User-defined Functions.
|
|
| Feb 20, 2012 at 10:37 | comment | added | Callie J |
You have to call a function through some SELECT statement - a function can't be called as an independent piece of code in its own right - it has to be called as part of some larger SQL statement, even if that SQL statement is nothing more than SELECT * from dbo.MyTableValuedFunction(). Sprocs, on the otherhand, can be called directly with ADO.NET by setting SqlCommand.CommandType to CommandType.StoredProcedure.
|
|
| Feb 20, 2012 at 9:00 | comment | added | Ian Kemp - SO dead by AI greed | Can you please elaborate on "Frameworks such as ADO.NET, etc. can't call a function directly"? I've executed functions with ADO.NET data providers with no issues. | |
| Sep 7, 2010 at 13:56 | history | edited | Tom H | CC BY-SA 2.5 |
deleted 6 characters in body
|
| Jul 24, 2009 at 20:06 | history | answered | Callie J | CC BY-SA 2.5 |