Retrieving SQL Server output variables in c#

后端 未结 5 1414
醉梦人生
醉梦人生 2020-12-18 04:25

I have a stored procedure:

ALTER PROCEDURE [dbo].[pr_Tbl_Test_Insert]
    @guidid uniqueidentifier output,
    @sname nvarchar(50)
AS
-- INSERT a new row in          


        
5条回答
  •  爱一瞬间的悲伤
    2020-12-18 04:57

    Why are you setting the @guidid uniqueidentifier output as an output parameter? It means it will override it once you execute the stored procedure. If that's your intention, then you need to add a statement after the insert statement to set the output parameter to the value you want. something like this: select @guidid = @generatedID. Yeah look at marc_s code, that's the way you are supposed to do it.

提交回复
热议问题