SQL Server Error "Invalid GetBytes attempt in column"

Little background:

I recently updated SQL Server 2005 Management Studio by applying the fix from the MS link http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7218

So, I can access the newly created database server, which is in the version of SQL Server 2008.

I have a link to a server created on a 2008 Db server that connects to an Oracle database. I did not encounter any problem before, but after applying the control studio patch, when I launch the request using the server link, as shown below

select top 10 * from [server]..DBNAME.TABLENAME 

OR

 select * from [server]..DBNAME.TABLENAME 

I get an error

An error occurred while executing the package. Error message: GetBytes attempted in colname 'column incorrectly. The GetBytes function can only be used for columns of type Text, NText, or Image. "

But if I changed the request to

 select top 10 col1,col2 from [server]..DBNAME.TABLENAME 

OR

 select distinct col1, col2, col3 from [server]..DBNAME.TABLENAME 

It works great without any problems.

I'm not sure, but I think this is related to Management Studio ... some settings in Management Studio are probably causing this problem.

Does anyone have any ideas or have run into this problem before. Can you help.

EDIT: if I run a problem request using sqlcmd , it works fine.

Thanks.

+7
source share
3 answers

I have this error before you use SQL 2005 management studio on SQL 2008 server and request a table with type DATE in it.

Essentially, this means that SSMS does not understand which of the column data types is returning to it. You said that SELECT * does not work, but SELECT col1, col2, col3. How many columns are in the table? Try expanding the selection column by column until you find one that is confusing Management Studio. You can then use CAST in the select clause to turn it into something that Management Studio understands.

What probably happens here is that one of the columns is returned from SQL 2008 as DATE, TIME, DATETIME2, or one of the other new SQL 2008 data types. Although Management Studio 2005 can connect to SQL 2008 server, it does not understand the new data types and cannot display them.

This is a limitation of Management Studio.

+12
source

as @GilaMonster stated the cause of the problem.

Again, the problem is with SSMS and is not common, for example, if I run a query using sqlcmd like

 sqlcmd -S <servername> -U login -P password -d dbname -Q "select top 10 * from [server]..DBNAME.TABLENAME" 

It works fine without errors.

Decision:

SSMS 2005 and install SQL Server 2008 R2 Management Studio , which will solve the problem.

0
source

I have found a solution. Try querying the sql2008 table containing the DATE field this way (assuming field3 is a DATE field):

 select field1, field2, convert(datetime,field3) from tablename 
0
source

All Articles