Gimmicks that work: XE Profiler in SQL Server Management Studio
I have a favourite new feature of SQL Server Management Studio 17.3 (SSMS), and that’s XE Profiler, which allows you to...
2017-11-01
506 reads
I have a favourite new feature of SQL Server Management Studio 17.3 (SSMS), and that’s XE Profiler, which allows you to...
2017-11-01
506 reads
This is more for my benefit in the future, but hopefully it can help someone else too. We recently had...
2017-10-25
4,515 reads
Recently, I was asked to assist an organization with getting their data back for a SQL Server that had experienced...
2017-10-18
655 reads
In the #sqlhelp Slack channel on the SQL Server Community Slack workspace last month, Jemma Hooper asked: When trying to...
2017-10-11
483 reads
For a few years now, Microsoft has augmented its irregular release of Service Packs with a more frequent Cumulative Update...
2017-10-04
468 reads
October is a busy month for me. I am flying all over the US and Canada for speaking engagements to...
2017-09-27
562 reads
I’ve been working with SQL Server for many years now, and up until recently, I assumed that rebuilding any clustered...
2017-09-20
456 reads
Joe Obbish wrote an epic post a few weeks ago about loading a trillion rows into a non-partitioned table in...
2017-09-13
462 reads
I got a strange request in a Slack channel the other day. A colleague in South Africa, who uses Windows,...
2017-09-06
406 reads
Last week, I posted this statement on Twitter, along with a screen capture of the official Microsoft documentation: Reminder: Max...
2017-08-30
368 reads
By Steve Jones
I’ve become an EV guy. I was talking with a friend who was selling...
In a previous post I talked about how we can use T-SQL Snapshot Backups...
By Steve Jones
A bit of a photo dump, but a few fun memories for me from...
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...
Comments posted to this topic are about the item Missing Returns
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