Pass a string to stored procedure as parameter with Identity ID
<p>I have a procedure like below that I passed a string as a parameter to it :</p>

<pre><code>CREATE PROCEDURE AddWantedJob
    (@JTID int ,
     @LocationID int,
     @OpeningDate datetime,
     @closingDate datetime,
     @JobDesc nvarchar(max),
     @InputQuery NVARCHAR(500))
AS
BEGIN
    BEGIN TRANSACTION

    DECLARE @JobID AS INT
    DECLARE @QueryString NVARCHAR(2000)

    SET @QueryString = 'insert into WantedJobWorkType (JobID , WTID ) values '
    SET @QueryString = @QueryString + @InputQuery

    INSERT INTO WantedJobs (JTID, LocationID, OpeningDate, closingDate, JobDesc) 
    VALUES (@JTID, @LocationID, @OpeningDate, @closingDate, @JobDesc)

    SET @JobID = SCOPE_IDENTITY()

    EXEC (@QueryString)
    COMMIT TRANSACTION
END
</code></pre>

<p>I passed string like <code>(@JobID, 1), (@JobID, 2 )</code> to it, but I get an error, why?</p>

<blockquote>
  <p>Msg 137, Level 15, State 2, Line 1<br>
  Must declare the scalar variable "@JobID".</p>
</blockquote>