Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

SQL table overwriting data

  • 03-07-2016 10:00PM
    #1
    Registered Users, Registered Users 2 Posts: 6,492 ✭✭✭


    Hi everyone I am a relative SQL newbie and I am updating an existing SQL database. I added a new table and my data is being stored however only on row 1 (so the data is constantly overwritten).

    Anyone know what I might be doing wrong? The table has 3 columns which are start time end time and tank name.


Comments

  • Registered Users, Registered Users 2, Paid Member Posts: 593 ✭✭✭sbs2010


    kingtut wrote: »
    Hi everyone I am a relative SQL newbie and I am updating an existing SQL database. I added a new table and my data is being stored however only on row 1 (so the data is constantly overwritten).

    Anyone know what I might be doing wrong? The table has 3 columns which are start time end time and tank name.

    What is the statement you are running - the statement that you think should be inserting but you're finding is updating the single row?


  • Registered Users, Registered Users 2 Posts: 6,492 ✭✭✭kingtut


    sbs2010 wrote: »
    What is the statement you are running - the statement that you think should be inserting but you're finding is updating the single row?

    I'm sorry I don't fully understand what you mean by a statement?

    If it helps I am using Factory talk transaction manager to grab data from a PLC and then storing it in SQL.

    For example I would expect the SQL table to look like:

    Row 1: 11:00 11:30 Tank 1
    Row 2: 14:00 14:20 Tank 5

    but all I see is one row of data so based on the above example my table currently shows

    Row 1: 14:00 14:20 Tank 5


  • Registered Users, Registered Users 2 Posts: 24,349 ✭✭✭✭Esel
    Not Your Ornery Onager


    Total guess here - not incrementing the row pointer?

    Not your ornery onager



  • Closed Accounts Posts: 27,833 ✭✭✭✭ThisRegard


    What's your key and database you're using?


  • Registered Users, Registered Users 2 Posts: 6,492 ✭✭✭kingtut


    Esel wrote: »
    Total guess here - not incrementing the row pointer?

    Hmm not sure about that, is there somewhere in particular I can check it? It's not something I can recall configuring. Is it a table property?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,492 ✭✭✭kingtut


    ThisRegard wrote: »
    What's your key and database you're using?

    Sorry total newb, not sure what you mean by key but it is an SQL database that pre-existed I am just adding a new table to it (the two tables the database previously are functioning perfectly).


  • Closed Accounts Posts: 27,833 ✭✭✭✭ThisRegard


    You shouldn't really need to worry about pointers in databases these days. Can you post the table definition?

    Each table in a database ideally has a key defined, such as an ID or some other unique field or combination of.

    SQL is just a language to interrogate databases, do you mean SQL Server?


  • Registered Users, Registered Users 2, Paid Member Posts: 593 ✭✭✭sbs2010


    OP - you need to read up a bit on the SQL language and how it it used to manipulate data in a relational database.

    There are four statement types -

    Update
    Insert
    Delete
    Select

    So you need to know how these work and how your application uses them to access the database.


  • Registered Users, Registered Users 2 Posts: 6,492 ✭✭✭kingtut


    Sorry everyone limited internet access.

    Ended up fixing both of my issues, for those curious (and for those who offered help) here is what I did:

    1) Table data being overwritten - I had the transaction set to 'update' rather than 'import'.
    2) vba issue in excel report - Excel version had been updated and one command was no longer valid.

    Thanks again everyone :)


Advertisement