Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Requete croisee

14 réponses
Avatar
SuperGolgoth
Bonjour à tous,
j'ai un petit soucis sur une requete qui attaque 2 BdD sur 2 SRV differents ...
Les 2 srvs sont des SQL Server 2000 (meme pack)
mais les bases sont légerement differentes (d'ou les COLLATE)
Voici la requete :

select UPPER(customer) 'customer', order_no, left((select distinct ficextid COLLATE French_BIN
from [SERVER1\INSTANCE1].[BASE1].dbo.table10
left join [SERVER1\INSTANCE1].[BASE1].dbo.table11 on ficid = offficid
where offtype = 'B' and offref COLLATE French_BIN = L.order_no) , 8) 'clientnv'
from [SERVER2\INSTANCE2].[BASE2].dbo.table20
where 'clientnv' COLLATE French_BIN <> 'customer' COLLATE French_BIN
order by order_no


le pb c'est que la clause 'where' en avant dernière ligne ne fonctionne pas du tout ...
que ce soit un <> ou un =, j'obtiens le meme resultat ...
comprends pas ...
Merci de votre aide

10 réponses

1 2
Avatar
Fred BROUARD
bonjour

SuperGolgoth a écrit :
Bonjour à tous,
j'ai un petit soucis sur une requete qui attaque 2 BdD sur 2 SRV differents ...
Les 2 srvs sont des SQL Server 2000 (meme pack)
mais les bases sont légerement differentes (d'ou les COLLATE)
Voici la requete :

select UPPER(customer) 'customer', order_no, left((select distinct ficextid COLLATE French_BIN
from [SERVER1INSTANCE1].[BASE1].dbo.table10
left join [SERVER1INSTANCE1].[BASE1].dbo.table11 on ficid = offficid
where offtype = 'B' and offref COLLATE French_BIN = L.order_no) , 8) 'clientnv'
from [SERVER2INSTANCE2].[BASE2].dbo.table20
where 'clientnv' COLLATE French_BIN <> 'customer' COLLATE French_BIN
order by order_no



vous ne devez pas préciser 2 clauses collate mais une seule...

where 'clientnv' <> 'customer' COLLATE French_BIN



le pb c'est que la clause 'where' en avant dernière ligne ne fonctionne pas du tout ...
que ce soit un <> ou un =, j'obtiens le meme resultat ...
comprends pas ...
Merci de votre aide






--
Frédéric BROUARD, MVP SQL Server, expert bases de données et langage SQL
Le site sur le langage SQL et les SGBDR : http://sqlpro.developpez.com
Audit, conseil, expertise, formation, modélisation, tuning, optimisation
*********************** http://www.sqlspot.com *************************
Avatar
SuperGolgoth
Effectivement, mais cela ne change rien ...


Fred BROUARD a formulé ce lundi :
bonjour

SuperGolgoth a écrit :
Bonjour à tous,
j'ai un petit soucis sur une requete qui attaque 2 BdD sur 2 SRV differents
...
Les 2 srvs sont des SQL Server 2000 (meme pack)
mais les bases sont légerement differentes (d'ou les COLLATE)
Voici la requete :

select UPPER(customer) 'customer', order_no, left((select distinct ficextid
COLLATE French_BIN
from [SERVER1INSTANCE1].[BASE1].dbo.table10
left join [SERVER1INSTANCE1].[BASE1].dbo.table11 on ficid = offficid
where offtype = 'B' and offref COLLATE French_BIN = L.order_no) , 8)
'clientnv'
from [SERVER2INSTANCE2].[BASE2].dbo.table20
where 'clientnv' COLLATE French_BIN <> 'customer' COLLATE French_BIN
order by order_no



vous ne devez pas préciser 2 clauses collate mais une seule...

where 'clientnv' <> 'customer' COLLATE French_BIN



le pb c'est que la clause 'where' en avant dernière ligne ne fonctionne pas
du tout ...
que ce soit un <> ou un =, j'obtiens le meme resultat ...
comprends pas ...
Merci de votre aide






Avatar
Fred BROUARD
Alors c'est que votre problème ne vient pas de là.

Donnez un jeu d'essais ainsi que les tables sous forme d'ordre DDL;

A +

SuperGolgoth a écrit :
Effectivement, mais cela ne change rien ...


Fred BROUARD a formulé ce lundi :
bonjour

SuperGolgoth a écrit :
Bonjour à tous,
j'ai un petit soucis sur une requete qui attaque 2 BdD sur 2 SRV
differents ...
Les 2 srvs sont des SQL Server 2000 (meme pack)
mais les bases sont légerement differentes (d'ou les COLLATE)
Voici la requete :

select UPPER(customer) 'customer', order_no, left((select distinct
ficextid COLLATE French_BIN
from [SERVER1INSTANCE1].[BASE1].dbo.table10
left join [SERVER1INSTANCE1].[BASE1].dbo.table11 on ficid =
offficid
where offtype = 'B' and offref COLLATE French_BIN = L.order_no)
, 8) 'clientnv'
from [SERVER2INSTANCE2].[BASE2].dbo.table20
where 'clientnv' COLLATE French_BIN <> 'customer' COLLATE French_BIN
order by order_no



vous ne devez pas préciser 2 clauses collate mais une seule...

where 'clientnv' <> 'customer' COLLATE French_BIN



le pb c'est que la clause 'where' en avant dernière ligne ne
fonctionne pas du tout ...
que ce soit un <> ou un =, j'obtiens le meme resultat ...
comprends pas ...
Merci de votre aide












--
Frédéric BROUARD, MVP SQL Server, expert bases de données et langage SQL
Le site sur le langage SQL et les SGBDR : http://sqlpro.developpez.com
Audit, conseil, expertise, formation, modélisation, tuning, optimisation
*********************** http://www.sqlspot.com *************************
Avatar
Patrice
Et sans entourer les alias entre guillemets dans la clause where ? (sinon on
compare en fait deux chaines litérales différentes).

--
Patrice

"SuperGolgoth" a écrit dans le message de news:

Effectivement, mais cela ne change rien ...


Fred BROUARD a formulé ce lundi :
bonjour

SuperGolgoth a écrit :
Bonjour à tous,
j'ai un petit soucis sur une requete qui attaque 2 BdD sur 2 SRV
differents ...
Les 2 srvs sont des SQL Server 2000 (meme pack)
mais les bases sont légerement differentes (d'ou les COLLATE)
Voici la requete :

select UPPER(customer) 'customer', order_no, left((select distinct
ficextid COLLATE French_BIN
from [SERVER1INSTANCE1].[BASE1].dbo.table10
left join [SERVER1INSTANCE1].[BASE1].dbo.table11 on ficid =
offficid
where offtype = 'B' and offref COLLATE French_BIN = L.order_no) ,
8) 'clientnv'
from [SERVER2INSTANCE2].[BASE2].dbo.table20
where 'clientnv' COLLATE French_BIN <> 'customer' COLLATE French_BIN
order by order_no



vous ne devez pas préciser 2 clauses collate mais une seule...

where 'clientnv' <> 'customer' COLLATE French_BIN



le pb c'est que la clause 'where' en avant dernière ligne ne fonctionne
pas du tout ...
que ce soit un <> ou un =, j'obtiens le meme resultat ...
comprends pas ...
Merci de votre aide









Avatar
SuperGolgoth
... dans ce cas je n'aurai aucun retour non ?
et en fait il me retourne TOUTES les lignes de BASE2 ...

Après mûre réflexion, Patrice a écrit :
Et sans entourer les alias entre guillemets dans la clause where ? (sinon on
compare en fait deux chaines litérales différentes).

--
Patrice

"SuperGolgoth" a écrit dans le message de news:

Effectivement, mais cela ne change rien ...


Fred BROUARD a formulé ce lundi :
bonjour

SuperGolgoth a écrit :
Bonjour à tous,
j'ai un petit soucis sur une requete qui attaque 2 BdD sur 2 SRV
differents ...
Les 2 srvs sont des SQL Server 2000 (meme pack)
mais les bases sont légerement differentes (d'ou les COLLATE)
Voici la requete :

select UPPER(customer) 'customer', order_no, left((select distinct
ficextid COLLATE French_BIN
from [SERVER1INSTANCE1].[BASE1].dbo.table10
left join [SERVER1INSTANCE1].[BASE1].dbo.table11 on ficid =
offficid
where offtype = 'B' and offref COLLATE French_BIN = L.order_no) , 8)
'clientnv'
from [SERVER2INSTANCE2].[BASE2].dbo.table20
where 'clientnv' COLLATE French_BIN <> 'customer' COLLATE French_BIN
order by order_no



vous ne devez pas préciser 2 clauses collate mais une seule...

where 'clientnv' <> 'customer' COLLATE French_BIN



le pb c'est que la clause 'where' en avant dernière ligne ne fonctionne
pas du tout ...
que ce soit un <> ou un =, j'obtiens le meme resultat ...
comprends pas ...
Merci de votre aide











Avatar
SuperGolgoth
je vous ai contacté par email ...

Fred BROUARD avait soumis l'idée :
Alors c'est que votre problème ne vient pas de là.

Donnez un jeu d'essais ainsi que les tables sous forme d'ordre DDL;

A +

SuperGolgoth a écrit :
Effectivement, mais cela ne change rien ...


Fred BROUARD a formulé ce lundi :
bonjour

SuperGolgoth a écrit :
Bonjour à tous,
j'ai un petit soucis sur une requete qui attaque 2 BdD sur 2 SRV
differents ...
Les 2 srvs sont des SQL Server 2000 (meme pack)
mais les bases sont légerement differentes (d'ou les COLLATE)
Voici la requete :

select UPPER(customer) 'customer', order_no, left((select distinct
ficextid COLLATE French_BIN
from [SERVER1INSTANCE1].[BASE1].dbo.table10
left join [SERVER1INSTANCE1].[BASE1].dbo.table11 on ficid =
offficid
where offtype = 'B' and offref COLLATE French_BIN = L.order_no) , 8)
'clientnv'
from [SERVER2INSTANCE2].[BASE2].dbo.table20
where 'clientnv' COLLATE French_BIN <> 'customer' COLLATE French_BIN
order by order_no



vous ne devez pas préciser 2 clauses collate mais une seule...

where 'clientnv' <> 'customer' COLLATE French_BIN



le pb c'est que la clause 'where' en avant dernière ligne ne fonctionne
pas du tout ...
que ce soit un <> ou un =, j'obtiens le meme resultat ...
comprends pas ...
Merci de votre aide












Avatar
SuperGolgoth
Est-ce que le pb ne viendrait pas de mauvais COLLATE ...
je viens de voir que la table OFFRES etait en French_CI_AS
et la table opheadm est en French_BIN ...
Dans ce cas, ma requete est-elle correcte ?
Je rappelle que je compare OFFRES.OffExtID et opheadm.order_no
Merci

CREATE TABLE [dbo].[OFFRES] (
[OffType] [char] (1) COLLATE French_CI_AS NULL ,
[OffID] [char] (10) COLLATE French_CI_AS NULL ,
[OffFicID] [char] (10) COLLATE French_CI_AS NULL ,
[OffDosID] [char] (10) COLLATE French_CI_AS NULL ,
[OffDestID] [char] (10) COLLATE French_CI_AS NULL ,
[OffRef] [char] (30) COLLATE French_CI_AS NULL ,
[OffExtID] [char] (30) COLLATE French_CI_AS NULL ,
[OffRev] [smallint] NULL

CREATE TABLE [scheme].[opheadm] (
[order_no] [char] (10) COLLATE French_BIN NOT NULL ,
[alpha] [char] (8) COLLATE French_BIN NOT NULL ,
[customer] [char] (8) COLLATE French_BIN NOT NULL ,
[address1] [char] (32) COLLATE French_BIN NOT NULL ,
[address2] [char] (32) COLLATE French_BIN NOT NULL ,
[address3] [char] (32) COLLATE French_BIN NOT NULL ,
[address4] [char] (32) COLLATE French_BIN NOT NULL ,
[address5] [char] (32) COLLATE French_BIN NOT NULL ,
[invoice_customer] [char] (8) COLLATE French_BIN NOT NULL ,
[statement_customer] [char] (8) COLLATE French_BIN NOT NULL ,
[group_customer] [char] (8) COLLATE French_BIN NOT NULL ,
Avatar
Fred BROUARD
Apparament vos id de jointure étant fait sur du CHAR (ce qui est loin
d'être une bonne idées, mais passons...) il faut aussi spécifier la
collation dans la jointure...

Queklque chose comme :

select UPPER(customer) AS customer,
order_no, left((select distinct ficextid COLLATE French_BIN
from [SERVER1INSTANCE1].[BASE1].dbo.table10
left join
[SERVER1INSTANCE1].[BASE1].dbo.table11
on ficid = offficid COLLATE French_BIN
where offtype = 'B'
and offref = L.order_no COLLATE French_BIN) ,
8) AS clientnv
from [SERVER2INSTANCE2].[BASE2].dbo.table20
where clientnv <> 'customer' COLLATE French_BIN
order by order_no

A +

SuperGolgoth a écrit :
Est-ce que le pb ne viendrait pas de mauvais COLLATE ...
je viens de voir que la table OFFRES etait en French_CI_AS
et la table opheadm est en French_BIN ...
Dans ce cas, ma requete est-elle correcte ?
Je rappelle que je compare OFFRES.OffExtID et opheadm.order_no
Merci

CREATE TABLE [dbo].[OFFRES] (
[OffType] [char] (1) COLLATE French_CI_AS NULL ,
[OffID] [char] (10) COLLATE French_CI_AS NULL ,
[OffFicID] [char] (10) COLLATE French_CI_AS NULL ,
[OffDosID] [char] (10) COLLATE French_CI_AS NULL ,
[OffDestID] [char] (10) COLLATE French_CI_AS NULL ,
[OffRef] [char] (30) COLLATE French_CI_AS NULL ,
[OffExtID] [char] (30) COLLATE French_CI_AS NULL ,
[OffRev] [smallint] NULL

CREATE TABLE [scheme].[opheadm] (
[order_no] [char] (10) COLLATE French_BIN NOT NULL ,
[alpha] [char] (8) COLLATE French_BIN NOT NULL ,
[customer] [char] (8) COLLATE French_BIN NOT NULL ,
[address1] [char] (32) COLLATE French_BIN NOT NULL ,
[address2] [char] (32) COLLATE French_BIN NOT NULL ,
[address3] [char] (32) COLLATE French_BIN NOT NULL ,
[address4] [char] (32) COLLATE French_BIN NOT NULL ,
[address5] [char] (32) COLLATE French_BIN NOT NULL ,
[invoice_customer] [char] (8) COLLATE French_BIN NOT NULL ,
[statement_customer] [char] (8) COLLATE French_BIN NOT NULL ,
[group_customer] [char] (8) COLLATE French_BIN NOT NULL ,






--
Frédéric BROUARD, MVP SQL Server, expert bases de données et langage SQL
Le site sur le langage SQL et les SGBDR : http://sqlpro.developpez.com
Audit, conseil, expertise, formation, modélisation, tuning, optimisation
*********************** http://www.sqlspot.com *************************
Avatar
SuperGolgoth
... et malheureusement j'ai toujours des retours que je ne devrais pas
avoir :

Displaying result for:
---------------------

select UPPER(LEFT(L.customer,8)) AS 'clil500',
L.order_no, left((select distinct F2.ficextid COLLATE
French_BIN
from [PLUTONNOVACIAL].[NOVA5PROD].dbo.fiches
F2
left join
[PLUTONNOVACIAL].[NOVA5PROD].dbo.offres O2
on F2.ficid = O2.offficid COLLATE
French_BIN
where O2.offtype = 'B'
and O2.offref = L.order_no COLLATE
French_BIN) , 8) AS 'clinov'
from [ATHENAL500].[BMDSA].scheme.opheadm L
where 'clinov' <> 'clil500' COLLATE French_BIN
order by L.order_no


clil500 order_no clinov
-------- ---------- --------
45031LON 000001 45031LON
67033 000002 67033
92036 000003 92036
21027STM 000004 21027STM
67051 000005 67051
21009 000006 21009
02021 000007 02021
18005POR 000008 18005POR
93059 000009 93059
02006 000010 02006
56005 000011 56005
30026 000012 30026
39003 0000121 39003
92047LAB 000013 92047LAB
92047LAB 000014 92047LAB
13032 000015 13032
34035MEU 000016 34035MEU
59007DEG 000017 59007DEG
34035MEU 000018 34035MEU
60030 000019 60030
13206 000020 13206
13111 000021 13111
82007 000022 82007
37001MAG 000023 37001MAG
95013CER 000024 95013CER
97NC0800 000025 97NC0800
97NC1400 000026 97NC1400
46001 000027 46001
67005BAS 000028 67005BAS
81007VAL 000029 81007VAL
14002MAG 000030 14002MAG
63016 000031 63016
etc ...


Fred BROUARD vient de nous annoncer :
Apparament vos id de jointure étant fait sur du CHAR (ce qui est loin d'être
une bonne idées, mais passons...) il faut aussi spécifier la collation dans
la jointure...

Queklque chose comme :

select UPPER(customer) AS customer,
order_no, left((select distinct ficextid COLLATE French_BIN
from [SERVER1INSTANCE1].[BASE1].dbo.table10
left join
[SERVER1INSTANCE1].[BASE1].dbo.table11
on ficid = offficid COLLATE French_BIN
where offtype = 'B'
and offref = L.order_no COLLATE French_BIN) , 8) AS
clientnv
from [SERVER2INSTANCE2].[BASE2].dbo.table20
where clientnv <> 'customer' COLLATE French_BIN
order by order_no

A +

SuperGolgoth a écrit :
Est-ce que le pb ne viendrait pas de mauvais COLLATE ...
je viens de voir que la table OFFRES etait en French_CI_AS
et la table opheadm est en French_BIN ...
Dans ce cas, ma requete est-elle correcte ?
Je rappelle que je compare OFFRES.OffExtID et opheadm.order_no
Merci

CREATE TABLE [dbo].[OFFRES] (
[OffType] [char] (1) COLLATE French_CI_AS NULL ,
[OffID] [char] (10) COLLATE French_CI_AS NULL ,
[OffFicID] [char] (10) COLLATE French_CI_AS NULL ,
[OffDosID] [char] (10) COLLATE French_CI_AS NULL ,
[OffDestID] [char] (10) COLLATE French_CI_AS NULL ,
[OffRef] [char] (30) COLLATE French_CI_AS NULL ,
[OffExtID] [char] (30) COLLATE French_CI_AS NULL ,
[OffRev] [smallint] NULL

CREATE TABLE [scheme].[opheadm] (
[order_no] [char] (10) COLLATE French_BIN NOT NULL ,
[alpha] [char] (8) COLLATE French_BIN NOT NULL ,
[customer] [char] (8) COLLATE French_BIN NOT NULL ,
[address1] [char] (32) COLLATE French_BIN NOT NULL ,
[address2] [char] (32) COLLATE French_BIN NOT NULL ,
[address3] [char] (32) COLLATE French_BIN NOT NULL ,
[address4] [char] (32) COLLATE French_BIN NOT NULL ,
[address5] [char] (32) COLLATE French_BIN NOT NULL ,
[invoice_customer] [char] (8) COLLATE French_BIN NOT NULL ,
[statement_customer] [char] (8) COLLATE French_BIN NOT NULL ,
[group_customer] [char] (8) COLLATE French_BIN NOT NULL ,






Avatar
SuperGolgoth
a l'inverse, si je remplace le <> par =, je n'ai plus rien !!!?????
comprends plus moi !

SuperGolgoth a présenté l'énoncé suivant :
... et malheureusement j'ai toujours des retours que je ne devrais pas avoir
:

Displaying result for:
---------------------

select UPPER(LEFT(L.customer,8)) AS 'clil500',
L.order_no, left((select distinct F2.ficextid COLLATE French_BIN
from [PLUTONNOVACIAL].[NOVA5PROD].dbo.fiches F2
left join
[PLUTONNOVACIAL].[NOVA5PROD].dbo.offres O2
on F2.ficid = O2.offficid COLLATE
French_BIN
where O2.offtype = 'B'
and O2.offref = L.order_no COLLATE French_BIN) , 8)
AS 'clinov'
from [ATHENAL500].[BMDSA].scheme.opheadm L
where 'clinov' <> 'clil500' COLLATE French_BIN
order by L.order_no


clil500 order_no clinov
-------- ---------- --------
45031LON 000001 45031LON
67033 000002 67033
92036 000003 92036
21027STM 000004 21027STM
67051 000005 67051
21009 000006 21009
02021 000007 02021
18005POR 000008 18005POR
93059 000009 93059
02006 000010 02006
56005 000011 56005
30026 000012 30026
39003 0000121 39003
92047LAB 000013 92047LAB
92047LAB 000014 92047LAB
13032 000015 13032
34035MEU 000016 34035MEU
59007DEG 000017 59007DEG
34035MEU 000018 34035MEU
60030 000019 60030
13206 000020 13206
13111 000021 13111
82007 000022 82007
37001MAG 000023 37001MAG
95013CER 000024 95013CER
97NC0800 000025 97NC0800
97NC1400 000026 97NC1400
46001 000027 46001
67005BAS 000028 67005BAS
81007VAL 000029 81007VAL
14002MAG 000030 14002MAG
63016 000031 63016
etc ...


Fred BROUARD vient de nous annoncer :
Apparament vos id de jointure étant fait sur du CHAR (ce qui est loin
d'être une bonne idées, mais passons...) il faut aussi spécifier la
collation dans la jointure...

Queklque chose comme :

select UPPER(customer) AS customer,
order_no, left((select distinct ficextid COLLATE French_BIN
from [SERVER1INSTANCE1].[BASE1].dbo.table10
left join
[SERVER1INSTANCE1].[BASE1].dbo.table11
on ficid = offficid COLLATE
French_BIN
where offtype = 'B'
and offref = L.order_no COLLATE French_BIN) , 8)
AS clientnv
from [SERVER2INSTANCE2].[BASE2].dbo.table20
where clientnv <> 'customer' COLLATE French_BIN
order by order_no

A +

SuperGolgoth a écrit :
Est-ce que le pb ne viendrait pas de mauvais COLLATE ...
je viens de voir que la table OFFRES etait en French_CI_AS
et la table opheadm est en French_BIN ...
Dans ce cas, ma requete est-elle correcte ?
Je rappelle que je compare OFFRES.OffExtID et opheadm.order_no
Merci

CREATE TABLE [dbo].[OFFRES] (
[OffType] [char] (1) COLLATE French_CI_AS NULL ,
[OffID] [char] (10) COLLATE French_CI_AS NULL ,
[OffFicID] [char] (10) COLLATE French_CI_AS NULL ,
[OffDosID] [char] (10) COLLATE French_CI_AS NULL ,
[OffDestID] [char] (10) COLLATE French_CI_AS NULL ,
[OffRef] [char] (30) COLLATE French_CI_AS NULL ,
[OffExtID] [char] (30) COLLATE French_CI_AS NULL ,
[OffRev] [smallint] NULL

CREATE TABLE [scheme].[opheadm] (
[order_no] [char] (10) COLLATE French_BIN NOT NULL ,
[alpha] [char] (8) COLLATE French_BIN NOT NULL ,
[customer] [char] (8) COLLATE French_BIN NOT NULL ,
[address1] [char] (32) COLLATE French_BIN NOT NULL ,
[address2] [char] (32) COLLATE French_BIN NOT NULL ,
[address3] [char] (32) COLLATE French_BIN NOT NULL ,
[address4] [char] (32) COLLATE French_BIN NOT NULL ,
[address5] [char] (32) COLLATE French_BIN NOT NULL ,
[invoice_customer] [char] (8) COLLATE French_BIN NOT NULL ,
[statement_customer] [char] (8) COLLATE French_BIN NOT NULL ,
[group_customer] [char] (8) COLLATE French_BIN NOT NULL ,







1 2