June 21, 2013 at 10:34 am
I am looking for a case statement that will only show me rows that Have the Column First name filled in, if the first name column is blank then I do not want to see the entire row...I hope I expained this correct
case when First.Name is null then ???
June 21, 2013 at 10:43 am
WHERE firstname IS NOT NULL?
'Only he who wanders finds new paths'
June 21, 2013 at 10:52 am
Or maybe this?
where ISNULL(firstname, '') > ''
This will exclude NULL and empty strings.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 21, 2013 at 10:55 am
sdhines3 (6/21/2013)
case when First.Name is null then ???
Life is complicated enough, why try to force the use of "case" there?
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.June 21, 2013 at 12:01 pm
Sean Lange (6/21/2013)
Or maybe this?
where ISNULL(firstname, '') > ''
This will exclude NULL and empty strings.
Sean,
there's no need for the ISNULL as NULL > '' won't return true. 🙂
where firstname > ''
Example:
DECLARE @test-2 TABLE(
firstname varchar( 50) NULL)
INSERT @test-2
VALUES( 'Luis'), (''), ('Sean'), (NULL), ('David')
SELECT * FROM @test-2
SELECT * FROM @test-2 WHERE firstname > ''
June 21, 2013 at 12:38 pm
Luis Cazares (6/21/2013)
Sean Lange (6/21/2013)
Or maybe this?
where ISNULL(firstname, '') > ''
This will exclude NULL and empty strings.
Sean,
there's no need for the ISNULL as NULL > '' won't return true. 🙂
where firstname > ''
Example:
DECLARE @test-2 TABLE(
firstname varchar( 50) NULL)
INSERT @test-2
VALUES( 'Luis'), (''), ('Sean'), (NULL), ('David')
SELECT * FROM @test-2
SELECT * FROM @test-2 WHERE firstname > ''
Good point Luis. 🙂
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
June 21, 2013 at 12:59 pm
Thanks everyone...Your suggesstions are right on target!
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply