i want to insert values in table descending order . like 5 4 3 2 1 means if new row inserted in table then 6 5 4 3 2 1.
please tell me fast
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Riddhi ValechaPosted Nov 3, 2014, 7:30 AM
The data will remain in back-end (say sql table).
While displaying, just write order by clause in descending order.
Wim SturkenboomPosted Nov 3, 2014, 7:10 AM
Inserting in a given sequence in a database table does NOT guarantee that they are retrieved in that order.
You can use the solution with clustered index above or the solution above with the 'order by' clause.
for what you want to achieve, I'll prefer the latter as it guarantees consistency (in case you later decide to modify the index).
Vikram AgrawalPosted Nov 3, 2014, 6:43 AM
Hi Priya,
You can do it with the help of indexes
To do this you have to create one clustered index on your table
follow the below example
CREATE CLUSTERED INDEX
[IndexName]
ON
[TableName]
(
[IDColumnName]
)
now whenever you select records from the table then it will automatic arranges in descending order
Dipankar BiswasPosted Nov 3, 2014, 3:56 AM