dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: INSERT INTO query with a WHERE clause problem

  1. #1
    Join Date
    Jun 2009
    Posts
    3

    INSERT INTO query with a WHERE clause problem

    Hello!

    I need to tansfer drivers from one main drivers table to a secondary table that's going to be used for an application. My first transfert was an easy one. I used an INSERT INTO statement to get every single driver form my main table. Now here's my problem: I need to keep my secondary table up to date since new drivers are being constantly entered in our main table. I tried to use the same INSERT INTO statement with a Where clause so that only new drivers would be added into my secondary drivers table. However, it won't work and I keep getting a Wrong column name error... Here's my query, if somebody could tell me why it won't work. Thanks!


    INSERT INTO attributionSql.dbo.chauffeur (noChauffeur, nomChauffeur, statut)
    SELECT CR.NumeroDeChauffeur, CR.Nom, CR.Statut_Actif_Inactif_Exclus
    FROM cis_win.cisadmin.ChauffeursRapid CR
    WHERE CR.NumeroDeChauffeur <> noChauffeur

  2. #2
    Join Date
    Aug 2009
    Posts
    2
    Try this ...

    INSERT INTO attributionSql.dbo.chauffeur (noChauffeur, nomChauffeur, statut) VALUES (
    SELECT CR.NumeroDeChauffeur, CR.Nom, CR.Statut_Actif_Inactif_Exclus
    FROM cis_win.cisadmin.ChauffeursRapid CR
    WHERE CR.NumeroDeChauffeur <> noChauffeur
    )

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles