How to insert row number using SQL

Tags:
Microsoft Access
Microsoft Excel
SQL
When importing data from Excel into MS Access, how do you insert a row number using SQL?
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 5  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • carlosdl
    How are you importing the data from Excel?
    84,805 pointsBadges:
    report
  • ToddN2000
    We need more info. How is the import being done via cut/paste or other method. Is the database set to use this row number as an id?
    133,750 pointsBadges:
    report
  • JimStAubin2015

    Excel sheet Field 1 that has 16 unique text values (a, b, c, ... p)

    Create a script (Macro and/or SQL) allowing user to insert a row number (always starting at 1) for a changing Excel sheet in one step:

    1. Import the Excel Spreadsheet A into MS Access Table A

    2. Alter Table A inserting UID (AutoNumber field type)

    3. Alter Table A by initializing UID with 1

    This should be a repeatable script even if the values in the Excel spreadsheet change (e.g., new Excel has 25 unique values)

    15 pointsBadges:
    report
  • ToddN2000
    Have you tried using the SQL method for adding row numbers to a table? ROW_NUMBER() over() as myrownbr
    133,750 pointsBadges:
    report
  • carlosdl
    Looks like a homework, but we might offer some help if you show us what you have tried.

    You pasted the problem description, but didn't answer the question about how you are importing the data.  Additionally, it looks to me that you don't need to assign the row number during the import, but afterwards.
    84,805 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: