Capture the name of the "current" table as a field on a Union query

  • Hello, all.

    I receive, routinelly, Excel files that I have to import into my DB. I have to populate the original name of the file and the name of the tab as fields (so later on the source can be tracked). No biggie. A script and Loop structures provide me what i need. However, some times instead of receiving the Excel files I receive a set of tables with the data already imported into them. These tables are named based on the original Excel file and the tab from which the data was imported. I need to bring those tables into my main table and populate the fields indicating the original name and tab; which should be easy. A simple union qry and braking the table name to populate the adequate fields. My problem is i can't get the correct syntax to capture the name of the table in each of the data sets.

    This has to be simple; however, my thick skull can't figure it out.

    Thx in advance for your suggestions.

    LRH

    If you don't have a destination,
    No matter how fast you travel
    You never get there.

  • Are u having C# code to import the Excel data ?

  • Like

    DataSet myDS = <Source> ;

    string TabName = myDS.Tables[1].Name ;

    ?

  • Sorry, guys, i was not clear.

    I am looking for a simple T-SQL query, that I can use to create a stored proc.

    Thx.

    LRH

    If you don't have a destination,
    No matter how fast you travel
    You never get there.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply