title: Passing VARBINARY to stored procedure
body: <p>I have some source data that is formatted as ASCII hexadecimal. I need to get it into a SQL database in  VARBINARY fields. I've reduced the problem to the bare minimum to illustrate what I'd like to do. I have a stored procedure:</p>
  
  <pre><code>CREATE PROCEDURE BinaryDemo
      @BinaryData varbinary(max)
  AS
  BEGIN
      PRINT @BinaryData;
  END
  </code></pre>
  
  <p>I know that it "works" because I can do:</p>
  
  <pre><code>DECLARE @tmp varbinary(max);
  SET @tmp = CONVERT(varbinary, '1234567890abcdef', 2);
  EXEC BinaryDemo @BinaryData=@tmp;
  </code></pre>
  
  <p>What I'd like to do is skip the intermediate steps and invoke the procedure like:</p>
  
  <pre><code>EXEC BinaryDemo @BinaryData=CONVERT(varbinary, '1234567890abcdef', 2);
  </code></pre>
  
  <p>Unfortunately, SQL complains about the syntax: <strong>Incorrect syntax near the keyword 'CONVERT'.</strong></p>
  
  <p>I know that the CONVERT is correct because I can:</p>
  
  <pre><code>PRINT CONVERT(varbinary, '1234567890abcdef', 2);
  </code></pre>
  
  <p>and I see exactly what I expect. The first example (declare/set/exec) is really a poor option because of the nature and quantity of the source data.</p>