title: Stored Procedures with arguments
body: <p>I can't make my stored procedure (SQL Server) run with NHibernate. I have following mapping:</p>
  
  <pre><code>&lt;sql-query name="udp_MyStoredProc"&gt;
      &lt;query-param name="Id" type="Int32" /&gt;
      &lt;query-param name="Name" type="String" /&gt;
      &lt;return-scalar column="ResId" type="Int32"/&gt;
      EXEC udp_MyStoredProc @Id = :Id, 
          @Name = :Name    
  &lt;/sql-query&gt;
  </code></pre>
  
  <p>Within code:</p>
  
  <pre><code>IQuery query = _HibSession.GetNamedQuery("udp_MyStoredProc");
  query.SetInt32("Id", id);
  query.SetString("Name", name);
  var res = query.List();
  </code></pre>
  
  <p>This results in following exception:</p>
  
  <blockquote>
    <p><code>[SQL: EXEC udp_MyStoredProc @Id =
    @p0, @Name = @p1] ---&gt;
    System.Data.SqlClient.SqlException:
    Procedure or function udp_MyStoredProc
    has too many arguments specified.</code></p>
  </blockquote>
  
  <p>I don't know what's wrong with the arguments? I also <a href="http://www.dotnetfunda.com/articles/article749-execute-stored-procedure-in-sql-server-using-nhibernate-.aspx" rel="nofollow">read</a> something about '?' as placeholders for the parameters, but I don't quite understand it.</p>
  
  <p>Signature of the Stored Procedure:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[udp_MyStoredProc]
  (
      @Id int,
      @Name NVARCHAR(255)
  )
  AS
  BEGIN  ... END
  </code></pre>
  
  <p>If I do something like this within Server Management Studio, it works:</p>
  
  <pre><code>EXEC udp_MyStoredProc  @Id = 30, @Name = 'test'
  </code></pre>
  
  <p>thx for any tipps.</p>
  
  <p>sl3dg3</p>