سؤال

The following code:

SELECT  *
FROM    portal.workflow AS w
        INNER JOIN portal.workflow_type AS wt
            ON w.workflow_type_id = wt.workflow_type_id
WHERE   wt.doc_type IN ('CentreEV', 'Expenditure Voucher')
        AND w.varchar_1 NOT IN (    select f1.BAT_NAME as 'DocumentFile'
                                    from openquery(QICRE_F1, 'select * 
                                                            from dbo.IO_GLF_BAT_CTL_VW 
                                                            where bat_stat = ''S'' ') f1
                                    where f1.USAGE_STAT = 'A'   ) 

Is throwing the following error:

Msg 468, Level 16, State 9, Line 1 Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "Latin1_General_CS_AS" in the equal to operation.

I've tried to fix this with the following, but I'm receiving a syntax error. I'm at a loss (even after looking at documention) how this should be done in this instance:

SELECT  *
FROM    portal.workflow AS w
        INNER JOIN portal.workflow_type AS wt
            ON w.workflow_type_id = wt.workflow_type_id
WHERE   wt.doc_type IN ('CentreEV', 'Expenditure Voucher')
        AND COLLATE Latin1_General_CI_AS w.varchar_1 NOT IN 
                                (   select f1.BAT_NAME as 'DocumentFile'
                                    from openquery(QICRE_F1, 'select * 
                                                            from dbo.IO_GLF_BAT_CTL_VW 
                                                            where bat_stat = ''S'' ') f1
                                    where f1.USAGE_STAT = 'A'   ) 
هل كانت مفيدة؟

المحلول

Possibly 2 issues with your query. Try something like this

...
WHERE ...
   AND w.varchar_1 COLLATE Latin1_General_CI_AS IN  
...

You may need to add that same syntax to your openquery command. This is where I'm not sure if it will work as you may need to use the linkedserver.database.schema.table syntax -- just need to test it. But something like this:

from openquery(QICRE_F1, 'select bat_name COLLATE Latin1_General_CI_AS  
   from dbo.IO_GLF_BAT_CTL_VW 
   where bat_stat = ''S'' ') f1

Good luck.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top