Tuesday, 28 August 2018

Stored procedure does not return result

I have written such a stored procedure, it must return a result, but it doesnt do that. it returns only a message that stored procedure runs successfully.

How should I change my SP?
CREATE PROCEDURE TestTVP
(
@param1 int,
@param2 int,
@a int OUTPUT
)
as
  SET NOCOUNT ON
  DECLARE @T1 as TABLE
 (
   PK INT IDENTITY NOT NULL,
   Wert INTEGER,
   Name INTEGER
 )
 INSERT INTO @T1(Wert,Name) VALUES (@param1,@param2)
 return select count(*) from @T1

 GO

exec TestTVP '1','22'


you have to pass OUTPUT parameter
declare @z int
exec TestTVP '1','22' ,@z output

and remove return from Stored Procedure make it only
...
select count(*) from @T1

0 comments:

Post a Comment