Dear All
I have the following SQL query which isn't returning the result that I would expect and so I want to inspect it a bit more closely. In particular, I would like to have a look at what dates SQL is using in the WHERE clause.
SELECT COUNT(Teacher.TeacherUsername) AS Total FROM Achievement INNER JOIN Teacher ON Achievement.AchievementRecordedBy = Teacher.TeacherFullname WHERE (Teacher.TeacherUsername = @Username) AND (Achievement.AchievementDate >= DATEADD(wk, DATEDIFF(wk,0,GETDATE()), -1) -- Sunday AND Achievement.AchievementDate <= DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 5)) -- Saturday
I figure there must be a really handy way to see what SQL Server is processing (i.e. to look at the actual query being executed). I've seen people use SQL Profiler before but that seems to bring up so many lines, it's not easy to trace this one query to see what's happening.
I would really appreciate any advice you may have.
Many thanks
Daniel