Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1091965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:36:45+00:00 2026-05-16T23:36:45+00:00

While trying to extract data from a view by joining it with two other

  • 0

While trying to extract data from a view by joining it with two other tables, I’m getting the following error: “SQL Server does not handle comparison of NText, Text, Xml, or Image data types.”

And here is the query:

    var expeditions = from VE in context.ViewExpeditions
                      join SIAGR in context.SiteInAdviseGoodsRef on VE.DeliveryNotes equals SIAGR.Value
                      join SIA in context.SiteInAdvise on SIAGR.SiteInAdviseId equals SIA.Id
                      where SIA.Id == SiteInAdviseID
                      select VE;

Here is the View ViewExpeditions:

SELECT ve.*, S.[$Refex] as SiteRefex,c.[$Refex] as ServiceRefex , DeliveryNotes = LEFT(o.list, LEN(o.list)-1),st.Status,st.StatusRefex 
from(
SELECT     
B.[$Id] AS Booking,
B.[$Refex] AS BookingRefex,
B.SiguxCPUE AS CartaDePorte,
SUM(ISNULL(BG.Weight, 0)) AS Weight,
SUM(ISNULL(BG.Volume, 0)) AS Volume,
ISNULL( SUBSTRING(B.Comments, 1, 100),'')  AS Comments, 
'Type' = 
      CASE 
         WHEN PickupSite IS NULL THEN 'Pickup'

         ELSE 'Delivery'
      END,
'Name' = 
      CASE 
         WHEN PickupSite IS NULL THEN PickupName

         ELSE DeliveryName
      END,
      'City' = 
      CASE 
         WHEN PickupSite IS NULL THEN PickupCity

         ELSE DeliveryCity
      END,
'PostalCode' = 
      CASE 
         WHEN PickupSite IS NULL THEN PickupPostalCode

         ELSE DeliveryPostalCode
      END,

'ContactName' = 
      CASE 
         WHEN PickupSite IS NULL THEN ISNULL(B.PickupContactName,'')

         ELSE ISNULL(B.DeliveryContactName,'')
      END,
 'ContactPhone' = 
      CASE 
         WHEN PickupSite IS NULL THEN ISNULL(B.PickupContactPhone,'')

         ELSE ISNULL( B.DeliveryContactPhone,'')
      END,



B.PickupDate AS DataExp,
B.DeliveryDate,
coalesce( B.PickupSite,B.DeliverySite) as 'Site',
b.Service,isnull(B.SiguxState,0) as SiguxState

FROM         dbo.BookingGoods AS BG 
INNER JOIN   dbo.Booking AS B ON BG.BookingId = B.[$Id] 

WHERE     (B.ExecutedBy = 2) AND B.SiguxCPUE is not null AND B.[$IsDeleted]=0
GROUP BY  B.PickupCity,b.PickupContactName,b.PickupContactPhone,b.PickupName,b.PickupPostalCode, B.DeliveryName,B.DeliverySite,  B.DeliveryCity, B.DeliveryPostalCode, B.DeliveryContactName, B.DeliveryContactPhone, B.PickupDate,  B.[$Id], B.SiguxCPUE, B.[$Refex], B.Comments,b.PickupSite,B.Service,B.SiguxState,B.DeliveryDate

) ve 
INNER join [ViewBookingActualStatus] st on st.Booking=ve.Booking
INNER join Service c on ve.Service=c.[$Id]
INNER JOIN dbo.Site AS S ON S.[$Id] = ve.Site   
 outer APPLY 
( 
        SELECT distinct
            CONVERT(VARCHAR(12), dbo.BookingGoodsRef.Value) + ', ' AS [text()] 
        FROM 
            dbo.BookingGoodsRef 
        WHERE 
            dbo.BookingGoodsRef.BookingId = ve.Booking and BookingGoodsRef.Type=13

        FOR XML PATH('') 
    ) o (list) 

Where am I going wrong about this?

NOTE: If I try to run the query in linqpad, it doesn’t give me any errors at all, and generates the following sql:

SELECT [t0].[Booking], [t0].[BookingRefex], [t0].[CartaDePorte], [t0].[Weight], [t0].[Volume], [t0].[Comments], [t0].[Type], [t0].[Name], [t0].[City], [t0].[PostalCode], [t0].[ContactName], [t0].[ContactPhone], [t0].[DataExp], [t0].[DeliveryDate], [t0].[Site], [t0].[Service], [t0].[SiguxState], [t0].[SiteRefex], [t0].[ServiceRefex], [t0].[DeliveryNotes], [t0].[Status], [t0].[StatusRefex]
FROM [ViewExpeditions] AS [t0]
INNER JOIN [SiteInAdviseGoodsRef] AS [t1] ON [t0].[DeliveryNotes] = [t1].[Value]
INNER JOIN [SiteInAdvise] AS [t2] ON [t1].[SiteInAdviseId] = [t2].[$Id]
WHERE [t2].[$Id] = @p0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:36:46+00:00Added an answer on May 16, 2026 at 11:36 pm

    If you copy the generated SQL from LinqPad into SSMS and try to run it, do you get the results you expect?

    I’d guess that the one of the columns on which you’re joining (probably DeliveryNotes) is ntext or text. SQL Server can’t join on text columns – you have to either cast both columns to varchar or use a substring on both columns.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to extract data from multiple Tables in a Word document. When trying
In PHP I am having difficulty trying to extract row data from one SQL
While trying to search with id sorting (and paginating) im getting from the log:
I'm trying to extract data from a many to many table configuration. I'm sorry
I'm trying to extract data from an xml file. A sample of my code
I've been trying to extract this data from a file but the thing is,
I am trying to extract level data from a PCM audio file using core
I am trying to extract data from this String: Hello there. Blah blahblah blah
I'm trying a query in PHP to connect and extract data from a MSSQL
Currently looking to extract data from 2 tables and insert into another. Tables as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.