TheBugSlayer
Programmer
Hi.
I am getting apparently inconsistent results while trying to discard rows where a column with TEXT datatype has a null value.
Query 1
returns 214 rows, most with Length > 0 but some have a length of NULL!
I tried a few permutations of the WHERE clause and no matter which one I use, there are rows with null length.
The database is in SQL Server 2008 but I am using Quest' s Toad for SQL Server to query it as my SQL Server 2005 SSMS does not allow me to connect to SQL Server 2008 databases.
Am I missing something? Any help is appreciated.
MCITP SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)
I am getting apparently inconsistent results while trying to discard rows where a column with TEXT datatype has a null value.
Query 1
Code:
[b]
SELECT C.Number AS CaseNumber,
ST.ObjectID AS SpecimenID,
ST.Gross ,
DataLength(ST.Gross)
FROM dbo.Case C WITH (NOLOCK)
JOIN dbo.Specimen ST ON ST.[CASE] = C.ObjectID
WHERE C.Number like 'C%' or C.Number like 'F%' or C.Number like 'N%' or C.Number like 'S%' AND
DATALENGTH(ST.Gross) > 0 -- OR DATALENGTH(ST.Gross) IS NOT NULL
[/b]
I tried a few permutations of the WHERE clause and no matter which one I use, there are rows with null length.
The database is in SQL Server 2008 but I am using Quest' s Toad for SQL Server to query it as my SQL Server 2005 SSMS does not allow me to connect to SQL Server 2008 databases.
Am I missing something? Any help is appreciated.
MCITP SQL Server 2005, MCTS SQL Server 2008 (DBD, DBA)