Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

ISNULL question Expand / Collapse
Author
Message
Posted Wednesday, April 10, 2013 1:53 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, December 12, 2014 1:02 PM
Points: 342, Visits: 884
I have difficult understanding this line of code

where ISNULL(myfield, 'N') = 'Y'

Does this mean
where myfeild is NULL or myfield = 'N' or myfield = 'Y'
Post #1441000
Posted Wednesday, April 10, 2013 2:00 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 12:03 PM
Points: 20,859, Visits: 32,880
SQL_Surfer (4/10/2013)
I have difficult understanding this line of code

where ISNULL(myfield, 'N') = 'Y'

Does this mean
where myfeild is NULL or myfield = 'N' or myfield = 'Y'


The string value 'N' will be provided for the comparision if the value of the column myfield is null.


Personally, I would simply use WHERE myfield = 'Y'. As it is currently coded the clause is not SARGable and will most likely not use an index on the column if one exists.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1441006
Posted Wednesday, April 10, 2013 3:48 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 1:51 PM
Points: 31,366, Visits: 15,831
What Lynn said.

Documentation is you need it: http://msdn.microsoft.com/en-us/library/ms184325.aspx







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1441053
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse