Hello,
I am trying to create a proc and at the end of the proc I want to call another proc and pass to one of the parameters to proc using the result from the "OUTPUT". Is it possible to use the results from the "OUTPUT" and use them as parameters?
Thanks.
USE [MyDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[stored_proc]
@Col2 varchar(32)
,@Col3 varchar(8)
,@Col4 varchar(15)
,@Col5 int
,@Col6 varchar(32)
AS
BEGIN
SET NOCOUNT ON
INSERT INTO [dbo].[Table1]
(Col2,
Col3,
Col4,
Col5,
Col6)
OUTPUT
Inserted.[Col1ID] AS [Col1ID]--Identity column
,Inserted.[Col2] AS [Col2]
,Inserted.[Col3] AS [Col3]
,Inserted.[Col4] AS [Col4]
,Inserted.[Col5] AS [Col5]
,Inserted.[Col6] AS [Col6]
VALUES
(@Col1ID--identity collumn
,@Col2
,@Col3
,@Col4
,@Col5
,@Col6
)
-- RETURN 1;
-- passing parameters from the "OUTPUT"
EXEC [dbo].[calling_stored_proc] @Col1ID=Inserted.[Col1ID], @Col2=Inserted.[Col2], @Col3=Inserted.[Col3]
END
GO