title: SP_EXECUTESQL and Output Parameter
body: <p>I would like get the ID from the query, but I am getting a NULL, where is my mistake?</p>
  
  <pre><code>DECLARE @TblZimz    NVARCHAR(256)
  DECLARE @IdModul    INTEGER
  DECLARE @Id         INTEGER
  
  SET @TblZimz        = '_ZIMZ000001'
  SET @IdModul        = 1
  --SET @Id               = -1
  
  EXECUTE [InsertZimz] @TblZimz, @IdModul, @Id OUTPUT
  
  
  
  
  ALTER PROCEDURE [InsertZimz]
  @TblZimz    NVARCHAR(256)
  , @IdModul  NVARCHAR(256)
  , @Id       INTEGER OUTPUT
  
              DECLARE @SqlQuery NVARCHAR(MAX)
          SET @SqlQuery = 'SELECT TOP (1) ([ID]) FROM ' + @TblZimz + ' WHERE [ModulId] = ' + @IdModul
  
          EXEC SP_EXECUTESQL @SqlQuery, N'@Id INTEGER OUTPUT', @Id OUTPUT
  </code></pre>
  
  <p>why the @Id Paramter is alwasy null? I cant see my mistake?</p>