How to group by a Calculated Field

Sure, just add the same calculation to the GROUP BY clause: select dateadd(day, -7, Convert(DateTime, mwspp.DateDue) + (7 – datepart(weekday, mwspp.DateDue))), sum(mwspp.QtyRequired) from manufacturingweekshortagepartpurchasing mwspp where mwspp.buildScheduleSimID = 10109 and mwspp.partID = 8366 group by dateadd(day, -7, Convert(DateTime, mwspp.DateDue) + (7 – datepart(weekday, mwspp.DateDue))) order by dateadd(day, -7, Convert(DateTime, mwspp.DateDue) + (7 – datepart(weekday, mwspp.DateDue))) … Read more

T-SQL Conditional Order By

CASE is an expression that returns a value. It is not for control-of-flow, like IF. And you can’t use IF within a query. Unfortunately, there are some limitations with CASE expressions that make it cumbersome to do what you want. For example, all of the branches in a CASE expression must return the same type, … Read more

What is “Connect Timeout” in sql server connection string?

That is the timeout to create the connection, NOT a timeout for commands executed over that connection. See for instance http://www.connectionstrings.com/all-sql-server-connection-string-keywords/ (note that the property is “Connect Timeout” (or “Connection Timeout”), not just “Timeout”) From the comments: It is not possible to set the command timeout through the connection string. However, the SqlCommand has a … Read more