Hello开发人员, 我有一个存储过程有输出参数,我想知道它们是否是一个更好的方法将返回值存储在变量中,因为我需要将它们分配给一个对象。该过程还接受两个参数并返回3个值。 我可以使用一个接收2个参数的方法并返回值 ALTER PROCEDURE [dbo]。[GetPurchaseUnitINDefaultUnit] - 在这里添加存储过程的参数 @quantity as decimal(20 ,4), @PurchaseUnitID为int, @TranslatedQuantity为十进制(20,4)输出, @DefaultUnitID as int输出, @DefaultUnitDesc as varchar(50)输出 谢谢
解决方案如果您在存储过程中使用SELECT语句,结果将返回给调用程序。这样结果将作为结果集处理,而不是作为输出参数处理。 例如,看看 www.sqlteam/article/stored-procedures-returning-data [ ^ ]
如果要返回多个值,那么你只有三个选项: 1)用你正在做的参数。 2)通过SELECT语句返回值。 或 3)将您的值转换为VARCHAR并将它们连接在一起。 我不会使用最后一个。
Hello developers, I have a stored procedure that has output parameter and i was wondering if their is a better way to store the returned values in a variable because i need to assign them to an object. the procedure also takes in two parameters and returns 3 values. can i have a method that takes in 2 arguments and returns me the values ALTER PROCEDURE [dbo].[GetPurchaseUnitINDefaultUnit] -- Add the parameters for the stored procedure here @quantity as decimal(20,4), @PurchaseUnitID as int, @TranslatedQuantity as decimal(20,4) output, @DefaultUnitID as int output, @DefaultUnitDesc as varchar(50) output thanks
解决方案 If you use a SELECT statement inside the stored procedure, the result is returned to the calling program. This way the result is handled as a result set, not as output parameters. For example have a look at www.sqlteam/article/stored-procedures-returning-data[^]If you are returning more than one value, then you have three options only: 1) Use out parameters as you are doing. 2) Return values via a SELECT statement. or 3) Convert your values to VARCHAR and concatenate them together. I wouldn''t use the last one.更多推荐
具有输出参数的tored过程
发布评论