sqldba2013
asked on
SQL Server Data type error
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.CP OA 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)
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
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)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER