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
 General SQL Server Forums
 New to SQL Server Programming
 Eliminating "NULL" text from result set

Author  Topic 

funk.phenomena
Posting Yak Master

121 Posts

Posted - 2011-05-25 : 15:07:24
Hi All -

I have a query that contains about 35 complex 'Select' statements and the results are saved as a .CSV file.

When I open the file in EXCEL, all fields with null values have the "NULL" text, in which I have to do a "Find and Replace"
every single time I save the file.

Without modifying each SELECT statement, is there a way to have NULL values presented as BLANK fields instead of displaying "NULL" ?

THANKS!

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-05-25 : 15:21:42
yes. Use ISNULL(field,'') for character fields. For numbers, you'd have to convert the field to char first.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

funk.phenomena
Posting Yak Master

121 Posts

Posted - 2011-05-25 : 15:27:20
Thanks, but doesn't that mean I have to modify every single SELECT statement with the ISNULL function?
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-05-25 : 15:41:01
Sorry, I missed that part in your OP I don't know of any way other than modifying all your select statements. You could write some vba to do the find and replace?

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

Bazalddo
Starting Member

22 Posts

Posted - 2011-05-26 : 05:52:08
jimf you may have to modify all your select statements but that would save you having to change the spreadsheet every single time. Might be a bit tedious changing them all but it will save time in the future! :)

Shahbaz Ahdi
Apps Developer
ODEON/UCI Cinema
Go to Top of Page

jfarrugia
Yak Posting Veteran

55 Posts

Posted - 2011-05-26 : 06:25:24
just throwing another option at you...or maybe you can just place an IF statement in excel as a formula which will replace NULL with whatever value you like.. but I'd suggest going with jimf's suggestion..its cleaner

Where software development knowledge meets the reader
Go to Top of Page
   

- Advertisement -