SQL Server – Find all the LOB Data Type Columns in a Database Using T-SQL Script
Today morning when I was working on a huge database containing lots of LOB data, I was required to know...
2013-09-12
890 reads
Today morning when I was working on a huge database containing lots of LOB data, I was required to know...
2013-09-12
890 reads
Even though there are more pros than cons, Striping database backups are often overlooked by many DBAs. Based on my...
2013-09-03
1,679 reads
Ever noticed and wondered why the well-known SQL Server system administrator (sa) login is in a disabled state? The reason...
2013-08-20
757 reads
Most of the DBAs at some point of time in their career should have faced at-least one of the below...
2013-08-10
1,407 reads
Cleaning/deleting the old backup files is equally important as taking the backups. Doing so we can (i) Avoid overhead cost for...
2013-08-07
1,012 reads
Earlier today I was required to pull the list of all SQL Login Accounts, Windows Login Accounts and Windows Group Login...
2013-08-06
1,426 reads
One of the first things I did when I began my journey with SQL Server was installing a sample database....
2013-07-31
1,610 reads
From a recent conversation with a customer, I noticed even some of the experienced DBAs are not very clear about...
2013-06-28
1,634 reads
By default, SQL Server automatically assigns a value to the Identity Column for each new row inserted into the table....
2013-06-02
680 reads
In SQL Serve 2012, we can get the default data file and log file locations using a simple T-SQL query...
2013-05-23
675 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...
WhatsApp:0817781222 Jl. Bina Insani No. 7G-7H, RT.003/RW.09, Kedung Jaya, Tanah Sareal, Kota Bogor, Jawa...
WhatsApp:0817781222 Jl. Kapten Muslihat No. 15 A, RT.01/RW.01, Pabaton, Kecamatan Bogor Tengah, Kota Bogor,...
Hi everyone, We previously used the Microsoft Access Database Engine 2016 (ACE) provider. As...
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