有人知道在执行存储函数后如何获取输出???
谢谢
答案 0 :(得分:0)
不确定您正在使用哪种语言,并且不确定您要查找的输出,但在C#/ ADO.NET中,您可以通过执行以下操作来获取选择查询输出到DataSet中:
SqlConnection sqlConnection = new SqlConnection(
"server=localhost\SQLEXPRESS;Integrated Security=SSPI;database=Northwind");
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("[MyStoredProc]", sqlConnection);
sqlDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
// Whatever selects your stored proc does will become tables in the DataSet
DataSet northwindDataSet = new DataSet("Northwind");
sqlConnection.Open();
sqlDataAdapter.Fill(northwindDataSet);
sqlConnection.Close();
// data now available in: dsNorthwind.Tables[0];, etc. depending on how many selects your query ran
答案 1 :(得分:0)
假设您想在T-SQL中使用OUTPUT参数的值,您可以执行以下操作:
CREATE PROC pTestProc (@in int, @out int OUTPUT)
AS
SET @Out = @In
SELECT 'Done'
RETURN 1
GO
DECLARE @Output INT
EXEC pTestProc 46, @Output OUTPUT
SELECT @Output
-Edoode