Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Looking for Empty or null

Author  Topic 

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2009-01-08 : 00:56:05
I just want to check something.

My query below is looking for the dateresolv column to be either empty or NULL does my query handle this in the most efficient manner?

SELECT cl.CustID, cl.CustType, cl.CallType , cl.CallStatus , cl.RecvdBy , cl.RecvdDate,  ass.AssignedBy, ass.DateAssign, ass.Assignee, ass.Notes

FROM Calllog cl JOIN Asgnmnt ass ON cl.Callid = ass.callid

WHERE cl.callstatus <> 'Closed' and (ass.DateResolv is null or ass.DateResolv = '' ) and ass.Assignee = 'Peter Piper'


TIA

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2009-01-08 : 01:11:00
What is the datatype of ur column dateresolv

Jai Krishna
Go to Top of Page

PeterNeo
Constraint Violating Yak Guru

357 Posts

Posted - 2009-01-08 : 01:11:35
Change the and condition to and ISNULL(ass.DateResolv, '') = '', always try to avoid OR operator in conditions.

"There is only one difference between a dream and an aim.
A dream requires soundless sleep to see,
whereas an aim requires sleepless efforts to achieve..!!"
Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-01-08 : 01:12:26
if Ur column dateresolv = '' then the system takes default time 1900-01-01 00:00:00.000 in ur query

Go to Top of Page

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2009-01-08 : 01:17:31
Out of interest the DateResolv field is a VarChar
Go to Top of Page

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2009-01-08 : 01:18:31
PeterNeo - What is that doing? (thanks by the way)
Go to Top of Page

icw
Constraint Violating Yak Guru

378 Posts

Posted - 2009-01-08 : 01:20:38
Don't worry I found it

Replaces NULL with the specified replacement value.

thanks again
Go to Top of Page
   

- Advertisement -