I'm having one web application where within loop I'm running one simple sql query (SQL Server 2008).
Select SNo, NoOfDays, [Month], [Year], [Days], [Holiday] From DaysMonth Where rtrim(Period)='Input' order by ToDate
Based on this query, populating one gridview and then creating records in a new table with other user input.
Now, out of 100 times it's running, 95-98 times it's giving accurate results, however, to my astonishment, sometimes sorting 'Order by' not working and producing abnormal sorting behavior. Like instead of 1st January to 31 January, it's returning 10th Jan-31st Jan then 1st Jan to 9th Jan (just for example). I got puzzled, because I can't do anything to change code, as it's working fine most of the time. Can you suggest some reason behind it which is beyond the code. As the data entry is huge, and it's multi-user environment, getting very difficult to monitor which one query going wrong. In that case, if I delete entries from new table, second time, it's giving perfect result. Please help me and thanks in advance to all.
Richard, I already deleted this question from C# forum. As you are suggesting, I think this is not related to SQL Server and it's muti-user web environment state management related problem. Anyway, if you think so, can I keep this question under this category and create a new thread in Database forum? Thanks for your suggestion.
Even if it was related to SQL Server, it has nothing to do with either C# or ASP.NET. It's pure SQL and you need to give some more information about the field you are using to sort on: i.e. its type and value.
One of these days I'm going to think of a really clever signature.
okay agreed. So I'll delete it from here and create under SQL. However, just to answer your query, 'ToDate' field is a 'Date' type field, not DateTime type. User input Period is a varchar type field, input value like 'January,2012'. Thanks
Last Visit: 31-Dec-99 19:00 Last Update: 26-Jan-15 21:30