Group by bit column

I want Group by rows with active column like result

I tray with this code and I Do not get result

    WITH CTE as (   SELECT     RN = ROW_NUMBER() OVER (ORDER BY id),     *   FROM test ) SELECT   convert(nvarchar(50),[Current Row].datetime,120) + ' To ' +  convert(nvarchar(50),[Next Row].datetime,120)  FROM CTE [Current Row] LEFT JOIN CTE [Previous Row] ON   [Previous Row].RN = [Current Row].RN - 1  and (ISNULL( [Previous Row].active,0)=0) and [Current Row].active=1 RIGHT JOIN CTE [Next Row] ON   [Next Row].RN = [Current Row].RN + 1  and [Current Row].active=1 and isnull([Next Row].active,0)=0 
id date active
1 2021-08-08 12:05:17.817 1
2 2021-08-08 12:05:20.817 1
3 2021-08-08 12:05:23.817 1
4 2021-08-08 12:05:26.817 1
5 2021-08-08 12:05:29.817 1
6 2021-08-08 12:05:32.817 1
7 2021-08-08 12:05:35.817 1
8 2021-08-08 12:05:38.817 1
9 2021-08-08 12:05:41.817 0
10 2021-08-08 12:05:44.817 0
11 2021-08-08 12:05:47.817 1
12 2021-08-08 12:05:50.817 1
13 2021-08-08 12:05:53.817 0
14 2021-08-08 12:05:56.817 0
15 2021-08-08 12:05:59.817 1
16 2021-08-08 12:06:02.817 0
17 2021-08-08 12:06:05.817 1
18 2021-08-08 12:06:08.817 1
19 2021-08-08 12:06:11.817 1
20 2021-08-08 12:06:14.817 0
21 2021-08-08 12:06:17.817 1
22 2021-08-08 12:06:20.817 1

and get rusult like this

date duration count
2021-08-08 12:05:17.817 To 2021-08-08 12:05:38.817 00:00:24 8
2021-08-08 12:05:47.817 To 2021-08-08 12:05:50.817 00:00:06 2
2021-08-08 12:05:56.817 To 2021-08-08 12:05:59.817 00:00:03 1
2021-08-08 12:06:05.817 To 2021-08-08 12:06:11.817 00:00:09 3
2021-08-08 12:06:17.817 To 2021-08-08 12:06:20.817 00:00:06 2

i want group by with active and date like top result

Is a point inside a graphics group composed of multiple Polygons and FilledCurves, not all overlapping?

I have many thousands of points, and I want to check if they are inside a GraphicsGroup that is composed of many Polygons and FilledCurves, similar to GeoWithin but without having to make tedious cloud inquiries.

I get RegionMember Errors and besides I suspect RegionMember is too smart to do a simple 2D numerical True/False test efficiently.

I’ve done this once many years ago by counting if a line from the point to infinity crossed all of the polygon segments an even or odd number of times, but would expect Mathematica to have an function already.

Generate more views & get likes on Social media (Tips, Group Links)

I had created a blog sharing my own tips and also a few Facebook groups which you could join to promote your content (Facebook, Instagram, Blog, website, etc)

This blog has very good information which will help you get more views/traffic and increase your likes, engagement.

Visit by copy-pasting this Link on your browser: https://like-booster.blogspot.com…

Generate more views & get likes on Social media (Tips, Group Links)

Instagram group for engagement

Hi folks, I came across a wonderful group on Facebook, which has amazing people who would love to connect with you on Instagram.

If you have an Instagram you would want to increase the engagement. To get started with meeting new & amazing people, kindly click here: https://www.facebook.com/groups/330482738785909…

Instagram group for engagement

Can’t remove “synchronizing/suspect” database after removed from availability group Sql Server 2019 Enterprise

I’ve removed a db from a synchronous availability group.The db shows "synchronizing/suspect" as it should. I’m trying to remove this database cannot. I have tried:

DROP DATABASE [db1]; 

but get "Cannot drop database "db1" because it is currently in use.". even though their are no sessions using this database.

ALTER DATABASE [db1] SET OFFLINE; 

but get "ALTER DATABASE failed because a lock could not be placed on database ‘db1’. Try again later."

ALTER DATABASE [db1] SET SINGLE_USER WITH ROLLBACK IMMEDIATE 

but get "ALTER DATABASE failed because a lock could not be placed on database ‘db1’. Try again later."

ALTER DATABASE [db1] SET EMERGENCY; 

ALTER DATABASE failed because a lock could not be placed on database ‘db1’. Try again later.

This is a 24/7 production db and restarting is not a good option.

Any advice?

Failover an Availability Group during a backup

This is a scenario I hope won’t happen, but if I was to perform a manual failover on an availability group halfway through a database backup will this cause the backup to fail or would it continue? I’ve been looking through MS documentation but can’t find this specific case.

I’m running SQL 2017 in an active – active environment with the listener in a third location. (synchronous commit)

(Backups are utilizing the Ola Hallengren scripts)

Availability Group- Redo Rate displayed on AG Dashboard vs Perfmon counter

I am bit confused on checking the metrics for REDO Rate KB/Sec from Always on AG dashboard which for some scenarios matches with perfmon counter Database replica : Redone Bytes/Sec ( hopefully its correct counter for redo rate via perfmon) and sometimes not at all.

Most of the times when there is lot of activity ongoing, my belief is that AG dashboard and DMV shows REDO rate for e.g. 40 MB/Secs at given time which matches with perfmon counter.

However during less activity time or nothing much to send over to sec, REDO Rate on Dashboard and dmv seems to be showing incorrect values compared to perfmon counter.

Not able to understand which value is correct and how to analyze. Any idea why or is it bug in dashboard?