title: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'
body: <p>I have an SQL server 2008 procedure which is returning one out parameter, i am giving call to it from java. My code is given below </p>
  
  <p>Stored procedure code is</p>
  
  <pre><code>Create PROCEDURE countInfected @infected int out
  AS
  Select @infected = COUNT(*) from userInfo
  where userID NOT IN (Select userID from deletedInfo);
  </code></pre>
  
  <p>Java Calling Code is</p>
  
  <pre><code>CallableStatement infected = null;
  infected = con.prepareCall("call countInfected(?)");
  infected.registerOutParameter(1, java.sql.Types.INTEGER);
  infected.execute();
  System.out.println("Infected"+ infected.getInt(1));
  </code></pre>
  
  <p>but infected.execute(); is generating the following error</p>
  
  <blockquote>
    <p>com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'</p>
  </blockquote>
  
  <p>kindly guide me where is problem</p>