I am trying to insert several records in sql server depending on the 'if' conditions on button press event. But the records are inserted irregularly in the sql server. For example first record is becoming 5th record and 5th record is becoming 8th. Can anybody help me?

  • I have a web page where several check boxes are provided. The visitor can choose certain number of choices out of the check boxes. I am trying

    to insert the options through 'if' conditions on button click event. But the records are stored at irregular

    record nos and not one after the other. For example first if condition is inserted in between the records

    already in the table and not as last record. Can anybody help me?

  • if you need order, then you'll have to tell it to the system.

    So add and "Predicate_order" column so you can sort your select set according to it.

    If you need rows in a certain order, you _have_ to use the "order by" clause in your final select !

    If you want to know when your row has been inserted, add a "insterded_datetime" not null with default getdate() column.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Is the record nos you're referring to a column in the table?

    Inserting a row into a table does not necessarily mean it will be stored in the last physical row. Even if you place some type of physical order on the table to make inserts occur at the end, for example using an identity column as the clustered index key on that table, there's no guarantee the data would be returned in that order.

    If you want a specific order in your results use the ORDER BY clause in the SELECT statement.

  • As mentioned before, the ordering of records is not guaranteed without an ORDER BY clause. If you want to display things in some order, be sure that you add a column that is used for ordering purposes or use one you have that makes sense.

  • Thank you very much

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

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