title: Calling SQLServer stored procedure from Sybase
body: <p>I'm writing a script in Sybase ASE where I call a stored procedure in SQL Server. The problem I have is that I'm getting an error from Sybase but not from SQL Server.</p>
  
  <p>The Script in <strong>Sybase</strong> is as follows:</p>
  
  <pre><code>declare @input varchar(4000)
  select @input = '111,222,333,444,555'
  exec GATEWAY.MyDataBase..MyStoredProcedure @input
  </code></pre>
  
  <p>And this is the error:</p>
  
  <blockquote>
    <p>[Error] Script lines: 1-5 --------------------------
     Conversion failed when converting the varchar value '555.............................................................................................................................................' to data type int.
     Msg: 245, Level: 16, State: 1
     Server: GATEWAY, Line: 0 </p>
  </blockquote>
  
  <p>My stored procedure in <strong>SQLServer</strong></p>
  
  <p>I don't know why Sybase adds that right padding. The only way I can get it work is declaring the variable <code>@input</code> as <code>varchar(255)</code> or shorter.</p>
  
  <p>What I tried without luck:</p>
  
  <ul>
  <li>Adding a rtrim and ltrim in sybase </li>
  <li>Setting the variable as TEXT </li>
  <li>Adding rtrim and ltrim in SQLServer</li>
  <li>adding a <code>replace(@input,' ', '')</code></li>
  <li>Wanted to replicate the problem in SQLServer adding the pad to the right but it still works.</li>
  </ul>
  
  <p>The important thing is that: <strong>I can excecute it from SQLServer but it throws error from Sybase with the same input data</strong>.</p>
  
  <p>Any help would be very appreciated. I guess it has something to do with the size of the varchar but no clue yet.</p>