SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Reporting problems with last name Null
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

wsilage
Yak Posting Veteran

USA
56 Posts

Posted - 03/05/2014 :  15:03:26  Show Profile  Reply with Quote
I have a person who's last name is actually NULL. How can I fix this so his last name pulls in my reports and not being actually blank.

Select Distinct
[PCS Number],
[Last Name],
[First Name],
[Address 1]
FROM [vw_All_Products]

Now I have two others that have the last name NULL as well and they are showing up.

DAVE NULL, LIZ, NULL AND CHRIS NULL. Chris Null is the one that is showing up with a blank Last name.

The last name field is varchar.

tkizer
Almighty SQL Goddess

USA
36844 Posts

Posted - 03/05/2014 :  15:32:50  Show Profile  Visit tkizer's Homepage  Reply with Quote
I think the difference is that those 2 that are showing up are actually named NULL, whereas Chris's last name doesn't have a value (is null).

Check this out:

Select Distinct
[PCS Number],
[Last Name],
[First Name],
[Address 1]
FROM [vw_All_Products]
where [Last Name] = 'NULL'


Select Distinct
[PCS Number],
[Last Name],
[First Name],
[Address 1]
FROM [vw_All_Products]
where [Last Name] IS NULL

So what do you want it to show up as?

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

maunishq
Yak Posting Veteran

Canada
71 Posts

Posted - 03/06/2014 :  11:09:09  Show Profile  Reply with Quote
If there is no last name for that particular person in your database, then how can you pull it? It shows NULL means there is no entry for that. Using the query provided by tkizer please check if the last name exist for those persons.

=======================
Not an Expert, Just a learner.
!_(M)_!
Go to Top of Page

wsilage
Yak Posting Veteran

USA
56 Posts

Posted - 03/07/2014 :  08:08:55  Show Profile  Reply with Quote
I Checked in the database and the last name is in there. There Persons last name is actually Null. My query that I run doesn't recogonize the persons name and things it is a null field, but it isn't.
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
36844 Posts

Posted - 03/07/2014 :  11:55:52  Show Profile  Visit tkizer's Homepage  Reply with Quote
You'll need to show us some sample data then.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000