I have 2 identical databases. 1 test db by me, and 1 production db by the customer
I have a (simplified) query that looks like this
ALTER VIEW nulltest as
SELECT isnull(NextDate,getdate()) as TillDate FROM (
SELECT LEAD(FromDate) OVER (partition by personid ORDER BY fromdate) AS NextDate
FROM Taxes)t
In reality the TillDate column will never be null, since it has an ISNULL function. But when i check the nullability of the query, i get 2 distinct answers. I check with this query
SELECT sys.columns.is_nullable FROM sys.columns INNER JOIN sys.objects ON sys.columns.object_id = sys.objects.object_id and sys.objects.name='nulltest'
On my db, I get a 1, and on the prod server I get a 0.
What gives?
UPDATE
FromDate in both databases is datetime2, not null
@@Version
DB 1: Microsoft SQL Server 2016 (SP1-GDR) (KB4019089) - 13.0.4206.0 (X64) Jul 6 2017 07:55:03 Copyright (c) Microsoft Corporation Developer Edition (64-bit) on Windows Server 2012 R2 Essentials 6.3 (Build 9600: )
DB 2: Microsoft SQL Server 2014 - 12.0.2000.8 (X64) Feb 20 2014 20:04:26 Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1)
Taxes.FromDatein both databases? - Jeroen MostertSELECT @@VERSIONgive on both systems, and what's the DB compat level? This could be a difference in optimizers. - Jeroen Mostert