A very stupid example, but if I need to get the maximum order ID from the order table, and I have two options (I know there are more of them, but I'm just interested in these two). I am interested to know what ends up with less overhead.
The first one that just selects the value:
CREATE PROCEDURE GetLastOrderID
AS
SELECT Max(OrderID) FROM Orders
and then the appropriate C # code to create an SQLCommand to execute proc, call .ExecuteScalar and pass the value to int.
The second, which passes the value as an output parameter
CREATE PROCEDURE GetLastOrderID (@MaxOrderID INT OUTPUT)
AS
SET @MaxOrderId = Max(OrderID) FROM Orders
and then the appropriate C # code to create the SQLCommand to execute proc, add an output parameter of type int, then call .ExecuteNonQuery and finally get the value of the output parameter.
- ? , /, , , . (, , , " " )