New answers tagged

2 votes
Accepted

Display in asc order from multiple databases under multiple linked server and add two date parameters so that I can integrate it to my app

As Dan pointed out in the comments, when you add an ORDER BY clause to the last query in a UNION ALL (or UNION) clause, the engine is smart enough to know you want the entire results of that UNION ALL ...
J.D.'s user avatar
  • 37.5k
2 votes
Accepted

Extra `CASE WHEN` Removes Text from Dynamically Created String

According to documentation this is antipattern known to return incorrect results: Avoid the following pattern for recursive use of variables and expressions: syntaxsql SELECT @Var = <expression ...
Yano_of_Queenscastle's user avatar

Top 50 recent answers are included