Bonjour à tous,
dans le case d'une migration des bases Access vers SQL SERVER, je suis amené à devoir réécrire les requêtes, je suis tombé sur l'une d'elles qui me cause des problèmes :
Code ACCESS : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 SELECT a.CodeAffaire, c1.NomEntreprise, c2.NomEntreprise, a.AdrFact, IIf(l.NumRemorque Is Not Null And l.NumRemorque Not Like "","Remorque",IIf(l.NumCamion Is Not Null And l.NumCamion Not Like "",IIf(l.NumBras Is Not Null And l.NumBras Not Like "","Camion-Bras","Camion"),IIf(l.NumBenne Is Not Null And l.NumBenne Not Like "","Benne",IIf(l.NumBras Is Not Null And l.NumBras Not Like "","Bras",IIf(l.NumEngin Is Not Null And l.NumEngin Not Like "","Engin",""))))) AS TypeMat, IIf(l.NumRemorque Is Not Null And l.NumRemorque Not Like "",l.NumRemorque,IIf(l.NumCamion Is Not Null And l.NumCamion Not Like "",IIf(l.NumBras Is Not Null And l.NumBras Not Like "",l.NumCamion & " - " & l.NumBras,l.NumCamion),IIf(l.NumBenne Is Not Null And l.NumBenne Not Like "",l.NumBenne,IIf(l.NumBras Is Not Null And l.NumBras Not Like "",l.NumBras,IIf(l.NumEngin Is Not Null And l.NumEngin Not Like "",l.NumEngin,""))))) AS NumMat FROM dbo_CLIENTS AS c1 RIGHT JOIN (dbo_CLIENTS AS c2 RIGHT JOIN (dbo_AFFAIRE AS a INNER JOIN [dbo_LIGNE-AFFAIRE] AS l ON a.CodeAffaire=l.CodeAffaire) ON a.Contremarque=c2.N°Client) ON a.N°Client=c1.N°Client WHERE a.CodeAffaire like "R*" and a.CodeAffaire not like "RD*" and a.CodeAffaire not like "RE*" and a.CodeAffaire not like "RP*" and a.Facture=no ORDER BY a.CodeAffaire;
Pour l'instant, j'ai fait cela
Code SQL SERVER : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 SELECT a.CodeAffaire, c1.NomEntreprise, c2.NomEntreprise, a.AdrFact, case when isnull(l.NumRemorque,'')='' then 'Remorque' else case when isnull(l.NumCamion,'')='' then (case when isnull(l.NumBras,'')='' then 'Camion-Bras' else 'Camion' end) else case when isnull(l.NumBenne,'')='' then 'Benne' else case when isnull(l.NumBras,'')='' then 'Bras' else case when isnull(l.NumEngin,'')='' then 'Engin' else '' end as TypeMat FROM dbo.CLIENTS AS c1 RIGHT JOIN (dbo.CLIENTS AS c2 RIGHT JOIN (dbo.AFFAIRE AS a INNER JOIN [dbo.LIGNE-AFFAIRE] AS l ON a.CodeAffaire=l.CodeAffaire) ON a.Contremarque=c2.numclient) ON a.numclient=c1.numclient WHERE a.CodeAffaire like 'R*' and a.CodeAffaire not like 'RD*' and a.CodeAffaire not like 'RE*' and a.CodeAffaire not like 'RP*' and a.Facture='no' ORDER BY a.CodeAffaire
Mais elle ne marche, j'ai comme message
Je ne vois pas d'où vient l'erreur, j'ai comme l'impression que cela vient de l'enchainement des CASE.Syntaxe incorrecte vers le mot clé 'as'.
Merci
Partager