I have been asked to migrate a website application from one server to another.
The code was written by previous developer.
He created a stored procedure with the following:
[Parameters]
@SurveyPeriodConfigID int = -1,
@StartDate DATETIME = NULL,
@EndDate DATETIME = NULL,
@StartTime DATETIME = [9:00:00],
@EndTime DATETIME = [19:00:00],
@Category INT = -1,
@SubcategoryID INT = -1,
@ReportType VARCHAR(50) = null,
@DepartmentID INT = -1,
@FloorID INT = -1,
@RoomID INT = -1,
@IsLazyLoad BIT = 0,
@Day INT = -1
and [WHERE caluse]:
SELECT [fields]
FROM [tables]
WHERE
(DATEPART(dw, rsdm.DateCreated)) != 7 AND (DATEPART(dw, rsdm.DateCreated)) !=1
AND rsdm.DateCreated BETWEEN @StartDate AND @EndDate
AND (CONVERT(VARCHAR(8),rsdm.DateCreated,108) BETWEEN @StartTime AND @EndTime)
AND (@Category = -1 OR rsdm.CategoryCodeID = @Category)
AND (@SubcategoryID = -1 OR rsdm.SubcategoryID = @SubcategoryID)
AND (@DepartmentID =-1 OR rsdm.DepartmentID = @DepartmentID)
AND (@FloorID =-1 OR rsdm.FloorID = @FloorID)
AND (@RoomID =-1 OR rsdm.RoomID = @RoomID)
AND (@Day =-1 OR DATEPART(dw, rsdm.DateCreated) = @Day)
C# Code:
SqlDataReader sqlDataReader = thisCommand.ExecuteReader(CommandBehavior.CloseConnection);
...calls the stored procedure and returns SqlDataReader.
So far so good.
Now the issue... previously the old site returned 8200 rows but now the new website returns 6500 rows!!!
I setup the code and website on my PC on my copy of sql database... it returns correct value of 8200. I then changed web.config to point to new website sql server... 6500 rows!!!
I backed up live site sql database and restored said same database locally on my PC and tested it... 8200 rows!!!
Old site had Sql server 2005, my PC has developer SQL 2012 whilst live server has SQL 2012.
I then ran sql profiler on new site Sql Server, extracted script and ran script on same sql database 8200 records!!!
I've spent the past 1-2 days on this and still no idea why live Sql Server return 6500 rows via sqldatareader.
Any suggestions would be greatly appreciated.