开发者

how to pass the result of SELECT statement to Stored Proc

what's the proper way to write it? Thx

  SELECT 
      [JobId] as jobid


  FROM [v_Jobs]
  WHERE jobreference =177127

EXEC    [dbo].[s_someStoredProc] @JobID =开发者_如何学JAVA jobid


You need to store that value in a variable:

DECLARE @MyJobID INT

SELECT 
      @MyJobID = [JobId]
FROM [v_Jobs]
WHERE jobreference =177127

EXEC  [dbo].[s_someStoredProc] @JobID = @MyJobID


If you're using MS SQL Server then you can do this very easily in Management studio. Rigth click on a stored procedure -> Execute -> Fill in the fields -> Management Studio generates a Query for you.

You can see how that works or just use the generated query.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜