MS SQL call function (not stored procedure)
See original GitHub issueHello.
I have a simple scalar-value sql function like
CREATE FUNCTION [dbo].[f_cost_1] RETURNS int AS BEGIN return 2000 END
And I`ve tried to call it from a .NETCoreApp 2.0 application like
var cost = db.ExecuteReader("f_cost_1"); //return empty reader
or
var cost = db.ExecuteProc<int>("f_cost_1"); //return 0
or
var cost = db.Execute<int>("f_cost_1"); //return 0
It works great with a stored procedure like
CREATE PROCEDURE [dbo].[f_cost_1] as begin select 2000 end
So how can I call a function properly and get return int result?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Why can we not execute a stored procedure inside ...
You cannot execute a stored procedure inside a function, because a function is not allowed to modify database state, and stored procedures ......
Read more >Execute a SQL Server procedure inside a function
According to Microsoft standard, stored procedures cannot be executed inside the function, but technically it is possible with some tweaks. How ...
Read more >Calling a Function From a Stored Procedure in SQL Server
In this article, we will see how to call a function from a stored procedure in SQL Server. In this article, we will...
Read more >Difference between Functions and Stored Procedures in ...
Functions can be called from a Select statement. Stored procedures cannot be called from a Select/Where or Having statements. Execute statement ...
Read more >Function vs. Stored Procedure in SQL Server
1 Answer ; The function always returns a value. Stored Procedure will not return a value, but the procedure can return “0” or...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I will mark it as feature request. To review if it makes sense to instroduce some helper like
T Sql.Function<T>(name, params)
Then don’t close it yet 😃