I am new to write store procedures in sql I want to use a store procedure into another store procedure Test is a store procedure which works fine but in usage store procedure I want stock is a table and stocks is a variable having the result value of this table with three column i.e : siteId,productId,id so i need to send all these rows of this table to another store procedure
CREATE PROCEDURE USAGE AS BEGIN
DECLARE stocks table(siteId int, stockId int, productId int)
DECLARE @i int
set stocks = 'insert into @stocks (siteId , stockId , productId)' +
'(select siteId, id, productId from "Stock")'
SET @i = 1
WHILE (@i<stocks.length)
EXEC Test stocks[@i].siteId, stocks[@i].stockId, stocks[@i].productId
END
select stocks
END
unable to get stocks in array/table format for accessing it getting the error Msg 156, Level 15, State 1, Procedure USAGE, Line 2 Incorrect syntax near the keyword 'table'
@
char:DECLARE @stocks table(siteId int, stockId int, productId int)
DECLARE (Transact-SQL), see Example C.