New answers tagged sql-server-2019
3
votes
Accepted
How to sum up the distinct Total Time of an Event ignoring duplicate overlaps in Times?
All the complexity results from the overlapping intervals.
If we pack the intervals so there are no overlaps, the solution is a straightforward group and sum.
The following code uses Itzik Ben-Gan's ...
2
votes
How to sum up the distinct Total Time of an Event ignoring duplicate overlaps in Times?
Here is a solution that uses Run Length Encoding to compress overlapping time ranges -
SCHEMA AND DESIRED OUTPUT
DROP TABLE IF EXISTS dbo.EventTimes;
CREATE TABLE dbo.EventTimes
(
EventTimeKeyId INT ...
0
votes
How do I filter down the latest Date from multiple columns
Here is a somewhat complex solution, but given your requirements this will work -
CREATE TABLE #sample
(
customer INT
, civil_status VARCHAR(32)
, civil_status_date DATE
, power_status ...
2
votes
Accepted
SQL Server remote insert fails, update works
"RPC is disabled on ServerA".
RPC and RPC OUT are settings on the linked server definition, not on the target server.
So just enable RPC OUT on the linked server definition and exec the ...
0
votes
Replace multiple words in a single value using SQL
I tweaked the query that Caleb provided to ensure we always stitch back the phrase in the order it was split and in order to do that i'm using OPENJSON split trick suggested by Aaron in an article. ...
1
vote
Accepted
Replace multiple words in a single value using SQL
One way to do this as of SQL 2022, is to split the values in each customer row, replace them, and then zip them back up again. Setting the enable_ordinal flag to 1 in the STRING_SPLIT() function ...
1
vote
In an Always On configuration, why do I have to open ports of the listener as well for the sql server engine itself for the listener ips?
listener01\instance01
You should never use instance names with a listener. Always use ports.
You can also designate a non-standard availability group listener
port. However, you also need to ...
Top 50 recent answers are included
Related Tags
sql-server-2019 × 912sql-server × 747
availability-groups × 62
t-sql × 35
execution-plan × 30
sql-server-2016 × 29
query-performance × 28
restore × 28
ssms × 28
clustering × 27
tempdb × 23
performance × 21
backup × 21
permissions × 21
ssis × 18
sql-server-2017 × 18
linux × 17
replication × 16
migration × 16
azure-sql-database × 16
transaction-log × 14
memory × 14
linked-server × 13
security × 12
json × 12