C#代码:
using (SqlCommand cmd = new SqlCommand(procName, connection))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(values);
cmd.Parameters.Add(new SqlParameter("@return_id", SqlDbType.VarChar, 20));
cmd.Parameters["@return_id"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
result = cmd.Parameters["@return_id"].Value.ToString();
}
SQL代码:
ALTER proc [dbo].[XXXXX](
@return_id varchar(5) OUT
)
AS
select @return_id = '1';