views:

80

answers:

2

Hey,

Does anyone know how to get the output after the execution of the stored function???

thank you

A: 

Not sure what language you're using, and not sure what output you're looking for, but in C#/ADO.NET, you can grab select query output into a DataSet by doing something like this:

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
Andy White
A: 

Assuming you'd want the value of an OUTPUT parameter in T-SQL you'd do something like this:

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

edosoft