Reputation
6,052
Top tag
Next privilege 10,000 Rep.
Access moderator tools
Badges
1 8 21
Newest
 Announcer
Impact
~146k people reached

1d
comment Join two tables and return data and count in a single query
But your count(*) means an empty list will show 1, not 0.
1d
revised Join two tables and return data and count in a single query
added 198 characters in body
1d
comment Join two tables and return data and count in a single query
You have one from me, @BogdanBogdanov
1d
comment Join two tables and return data and count in a single query
Fixed my typo...
1d
revised Join two tables and return data and count in a single query
added 2 characters in body
1d
comment Join two tables and return data and count in a single query
@BogdanBogdanov Actually, it shouldn't matter much. The bigger question is whether an empty list should still be returned, which is why I used an outer join.
1d
answered Join two tables and return data and count in a single query
1d
answered Running a T-SQL job under another user
Apr
21
comment Check if any of the values is in a subquery result
A temporary table is less likely to perform well, as it prevents many optimisation opportunities.
Apr
21
comment Check if any of the values is in a subquery result
A CTE isn't designed for this purpose. It would still be expanded into the main query twice. Try and see...
Apr
21
comment Check if any of the values is in a subquery result
Clearer now? The whole point of this is to ensure that the complicated subquery is only executed one time. That doesn't happen with a CTE, or by replacing two INs with two EXISTSs.
Apr
21
revised Check if any of the values is in a subquery result
added 378 characters in body
Apr
21
comment Check if any of the values is in a subquery result
The OP said its a single subquery that returns a list of values. I'll edit to make it clearer.
Apr
21
comment Check if any of the values is in a subquery result
Because it uses your subquery one time instead of twice.
Apr
21
answered Check if any of the values is in a subquery result
Apr
20
revised When doing an update on a set of records, how do i get previous updates to show on current row to update in UDF
added 421 characters in body
Apr
20
revised When doing an update on a set of records, how do i get previous updates to show on current row to update in UDF
added 246 characters in body; edited body
Apr
19
comment When doing an update on a set of records, how do i get previous updates to show on current row to update in UDF
Further change made.
Apr
19
revised When doing an update on a set of records, how do i get previous updates to show on current row to update in UDF
added 646 characters in body
Apr
19
comment When doing an update on a set of records, how do i get previous updates to show on current row to update in UDF
UDFs have issues. It's not about being a purist. UDFs run as procedural code, so they will see changes that have been made by previously executed procedural code within that transaction.