?
Solved

SQL Server Data type error

Posted on 2014-03-07
2
Medium Priority
?
944 Views
Last Modified: 2014-03-07
Hi Experts,

I am facing an data type error while running below query. Please advise how to fix below error.

SELECT  Inquiries,[PO Number], max(Revision) AS MaxRevision
FROM [LinkedServer_1].[Database_1].dbo.CPOA  WITH(NOLOCK)
GROUP BY Inquiries ,[PO Number]

Error:
Msg 306, Level 16, State 2, Line 3
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.

Data type:
---------
Inquiries varchar(max)
[PO Number] varchar(50)
Revision varchar(50)

Source server version:
Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)   Jun 28 2012 08:36:30   Copyright (c) Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor)

Destination version (lnked server version):
Microsoft SQL Server 2008 (SP3) - 10.0.5500.0 (X64)   Sep 21 2011 22:45:45   Copyright (c) 1988-2008 Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
0
Comment
Question by:sqldba2013
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 1000 total points
ID: 39911921
I think Inquiries field is having text datatype

work around for this

SELECT
CAST(Inquiries AS NVARCHAR(1000)) Inquiries
 ,[PO Number], max(Revision) AS MaxRevision
FROM [LinkedServer_1].[Database_1].dbo.CPOA  WITH(NOLOCK)
GROUP BY CAST(Inquiries AS NVARCHAR(1000))  ,[PO Number]
0
 

Author Closing Comment

by:sqldba2013
ID: 39912111
--
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question