3
votes

I'm trying to transfer columns from database tables into a fact table in a data warehouse.

I'm using the following SQL command to retrieve data

SELECT employée.matricule, accident.[code accident], prestataire.[N°], 
visite.[date visite], accident.[date accident] ,remboursement.[montant rem], visite.[Nbre Jours Acc] 
FROM 
    visite, employée, accident, prestataire, remboursement, bordereaux
WHERE 
    employée.matricule=accident.matricule AND 
    employée.matricule= visite.matricule AND
    prestataire.valeur = bordereaux.prestataire AND
    bordereaux.matricule = employée.matricule AND
    remboursement.[numéro du bulletin] = bodereaux.[numéro du bulletin]

The column [numéro du bulletin] exists in the table "bodereaux" and "remboursement" but I don't understand why I keep getting this error

Error 2
Validation error. Data Flow Task OLE DB Source [48]: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E14. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E14 Description: "Statement(s) could not be prepared.". An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E14 Description: "The multi-part identifier "bodereaux.numéro du bulletin" could not be bound.". FaitAccident.dtsx 0 0

1
Bad habits to kick : using old-style JOINs - that old-style comma-separated list of tables style was replaced with the proper ANSI JOIN syntax in the ANSI-92 SQL Standard (more than 25 years ago) and its use is discouraged - marc_s
Can you give me an example please? the link that you gave me doesn't work - MightyTurtle

1 Answers

0
votes

Try using the following query:

SELECT 
    employée.matricule, 
    accident.[code accident], 
    prestataire.[N°], 
    visite.[date visite], 
    accident.[date accident], 
    remboursement.[montant rem], 
    visite.[Nbre Jours Acc] 
FROM 
    visite INNER JOIN employée ON employée.matricule = visite.matricule
           INNER JOIN accident ON employée.matricule = accident.matricule
           INNER JOIN bordereaux ON bordereaux.matricule = employée.matricule
           INNER JOIN remboursement ON remboursement.[numéro du bulletin] = bodereaux.[numéro du bulletin]
           INNER JOIN prestataire ON prestataire.valeur = bordereaux.prestataire