How to Grant Permissions Only on the Replica in Database Mirroring and AlwaysOn AG
You work with Database Mirroring or AlwaysOn AG, and you want to make sure your end users work only on...
2016-03-03
317 reads
You work with Database Mirroring or AlwaysOn AG, and you want to make sure your end users work only on...
2016-03-03
317 reads
Happy 2016!
I continue my tradition of summarizing the things I learned in the past year (as a reminder, here’s what...
2016-01-25
666 reads
In the previous post, we talked about when you should use identity/sequence as a clustered index key and when it’s...
2016-01-19
1,368 reads
A few days ago, while delivering my session, The Data-Loading Performance Presentation, I was asked when, performance-wise, Identity should be...
2015-12-28 (first published: 2015-12-16)
3,848 reads
A few days ago I returned from PASS Summit 2015 (and a vacation I took afterwards). Here’s my recap: I...
2015-11-22
684 reads
I have just finished delivering my session, The Data Loading Performance Presentation at PASS Summit 2015. It went very well,...
2015-10-30
1,070 reads
Nolock is not the Satan, but no an angel too
Surfing the web you will find articles saying that Nolock is...
2015-10-26
501 reads
AlwaysOn Availability Groups is a great technology that centralizes the management of High Availability, Disaster Recovery and Scale-Out. However, in...
2015-09-24
1,343 reads
This weekend, I’ll hop on a plane and fly over to Norway for SQLSaturday Oslo.
I’ll be delivering a session I...
2015-08-26
769 reads
Last week, I gave a presentation about SQL Server’s data warehouse capabilities, and specifically about APS (Analytics Platform System) and...
2015-08-19
1,146 reads
By Brian Kelley
I once kept a gratitude journal and I still have a task on my...
By Arun Sirpal
The goal is simple: register AgentDBA as an MCP server in Claude Code, so...
By Steve Jones
I was excited to try out the latest release of SSMS, v22.12.1 for this...
Hi everyone, We previously used the Microsoft Access Database Engine 2016 (ACE) provider. As...
Hello, We recently migrated a database from SQL Server 2014 to SQL Server 2022....
Comments posted to this topic are about the item Detecting Outliers in Power BI...
I have a few tables in my SQL 2025 database:
CREATE TABLE [dbo].[Customer] ( [CustomerID] [int] NOT NULL, [CustomerName] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [AddressKey] [int] NULL, [CustomerStatus] [int] NULL, [CustomerContact] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [ContactEmail] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, [PreferredName] [char] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY] GO ALTER TABLE [dbo].[Customer] ADD CONSTRAINT [CustomerPK] PRIMARY KEY CLUSTERED ([CustomerID]) ON [PRIMARY] GO CREATE TABLE [dbo].[Orders] ( [OrderID] [int] NOT NULL, [CustomerID] [int] NOT NULL, [ProductID] [int] NOT NULL, [OrderDate] [date] NOT NULL, [Quantity] [int] NOT NULL ) ON [PRIMARY] GO ALTER TABLE [dbo].[Orders] ADD CONSTRAINT [PK__Orders__C3905BAFE0146D59] PRIMARY KEY CLUSTERED ([OrderID]) ON [PRIMARY] GO ALTER TABLE [dbo].[Orders] ADD CONSTRAINT [FK_Orders_Customers] FOREIGN KEY ([CustomerID]) REFERENCES [dbo].[Customers] ([CustomerID]) GO ALTER TABLE [dbo].[Orders] ADD CONSTRAINT [FK_Orders_Products] FOREIGN KEY ([ProductID]) REFERENCES [dbo].[Products] ([ProductID]) GO CREATE TABLE dbo.CustomerReturn ( EntryID INT NOT NULL CONSTRAINT CustomerReturnPK PRIMARY KEY , CustomerID INT , ReturnDate DATETIME , OrderID INT NOT NULL ) GOThere are multiple rows in all these tables. I am trying to find how many customers have never returned anything, and I run this:
SELECT count(*)
FROM dbo.Customer
WHERE CustomerID NOT IN
(
SELECT CustomerID FROM dbo.CustomerReturn
);
I get zero rows, but I know there are customers who have not returned anything. What is wrong? See possible answers