Access UNION query RRS feed

  • Question

  • Hello all,

    I have several excel files that I have linked in an access db (not imported). There I call a UNION query and brings all fields (all excel files are the same- only data changes) into one big table in access. So far so good.

    I would like though to have an identifier based on the excel imported. So, if I have excel1, excel2 etc I want to add also automatically in my access table a new field called for instance "excel source" and having there marked from which excel file the data is coming from.

    Is that possible ? Any help appreciated!

    Tuesday, May 31, 2016 3:02 PM


All replies

  • Hi. You can add a calculated column in your UNION query. For example:

    SELECT "Excel1" As FileName, Field1 FROM Excel1
    UNION SELECT "Excel2", Field1 FROM Excel2


    Hope it helps...

    Tuesday, May 31, 2016 3:36 PM
  • Hi KKaras,

    I think the suggestion given by the DB guy can solve your issue.

    please check the suggestion given by him and let us know whether it worked for you or not.

    if you find that the suggestion given by the DB guy solves your issue then please mark the suggestion given by him as an Answer.



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 1, 2016 1:34 AM