|I have a simple SQL table as follows:
CREATE TABLE [dbo].[DaysMonth](
[SNo] [int] NOT NULL,
[Month] [varchar](20) NOT NULL,
[Year] [varchar](4) NOT NULL,
[NoOfDays] [int] NOT NULL,
[Days] [nchar](10) NULL,
[Holiday] [nchar](1) NULL,
[ToDate] [date] NULL,
[Period] [nchar](30) NULL,
Following is the query:
Select SNo, NoOfDays, [Month], [Year], [Days], [Holiday] From DaysMonth Where [Period]='November,2012' order by ToDate
Now, i'm using this query in web application using ASP.Net environment and C# language within a loop. using SQL Server 2008. basic purpose here is to get all days within a period, say January,2012 in a sorted manner.
Out of 100 times running this query, 97-98 times, it's producing correct result, however, 1-2 times, sort is not working, so instead of 1st to 31st, output coming like 10th to 31st then 1st to 10th. Getting puzzled, as it's a huge application running on multi-user environment, getting very difficult to take care of error which is absolutely unpredictable and illogical. Please suggest where is the problem, thanks to all in advance.