title: SQL Server Error "Invalid attempt to GetBytes on column"
body: <p>Little background:</p>
  
  <p>Recently I upgraded "SQL server management studio 2005" by applying the patch from MS link
  <a href="http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=7218" rel="noreferrer">http://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=7218</a></p>
  
  <p>So that, I can access the recently built DB server which are in SQL Server 2008 version.</p>
  
  <p>I have a server link created on the 2008 Db server which connects to a Oracle DB. earlier I didn't faced any issue but after applying the management studio patch whenever I run a query using the server link as below</p>
  
  <pre><code>select top 10 * from [server]..DBNAME.TABLENAME 
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>select * from [server]..DBNAME.TABLENAME 
  </code></pre>
  
  <p>I get the error</p>
  
  <blockquote>
    <p>An error occurred while executing batch. Error message is: Invalid
    attempt to GetBytes on column colname'. The GetBytes
    function can only be used on columns of type Text, NText, or Image."</p>
  </blockquote>
  
  <p>But if I change the query to </p>
  
  <pre><code>select top 10 col1,col2 from [server]..DBNAME.TABLENAME 
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>select distinct col1, col2, col3 from [server]..DBNAME.TABLENAME 
  </code></pre>
  
  <p>It runs fine without any issue.</p>
  
  <p>I am not sure but my believe is it's something to do with <code>Management Studio</code> ... some setting in <code>Management Studio</code> probably causing this issue.</p>
  
  <p>Does anyone have any idea Or have faced this issue before. Can you please help.</p>
  
  <p>EDIT: If I run the problem query using <code>sqlcmd</code> it runs fine.</p>
  
  <p>Thanks.</p>