I used to know how to do this but have forgotten. How do I set a variable to an item returned by a query using TSQL (SQL Server). I have delcared my @variable and need to set it to an item returned by ...
In this third in a series on working smarter with T-SQL, let's give the built-in sp_executesql stored proc a go. In my previous posts, I've described some methods for generating and executing T-SQL ...
Use a CTE that returns the row ID and the result of the DateDiff, then join that to your existing result set? It may or may not be faster, so as always, test it to see.
Some results have been hidden because they may be inaccessible to you
Show inaccessible results