LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-23-2010, 01:22 PM   #1
action_owl
Member
 
Registered: Jan 2009
Location: 127.0.0.1
Distribution: Fedora, CentOS, NetBSD
Posts: 115

Rep: Reputation: 17
SQL select/NULL question


If I have a Query that returns columns where some of the values are NULL, is it possible to tell SQL to return all the NULL values as empty strings instead of the NULL datatype?

If the solution is vendor specific I am (unfortunately) using a Microsoft 2008 SQL server.

Example:

Code:
Select * from imaginary_table where id = 1
Might return:
Code:
Id: 	1
Name:	xyz
Value: 	this
Etc: 	NULL
Stuff: 	NULL
But what I would want it to return is:
Code:
Id: 	1
Name:	xyz
Value: 	this
Etc: 	
Stuff:
 
Old 12-23-2010, 01:31 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Let me google this for you ...


Funnily enough the first 4 links are references to T-SQL,
the MS products dialect ;}


Cheers,
Tink
 
Old 12-23-2010, 07:18 PM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled

Quote:
Funnily enough the first 4 links are references to T-SQL,
the MS products dialect ;}
The "select case" technique is probably the one I'd choose...
 
Old 12-23-2010, 08:24 PM   #4
BenCollver
Rogue Class
 
Registered: Sep 2006
Location: OR, USA
Distribution: Slackware64-15.0
Posts: 376
Blog Entries: 2

Rep: Reputation: 172Reputation: 172
I like coalesce.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about SQL: Can you do this, select records depending on the value of a char? vxc69 Programming 3 12-18-2008 08:11 PM
SQL question - checking for NULL? BrianK Programming 2 04-13-2007 10:11 AM
SQL SELECT Group by 2 conditions MicahCarrick Programming 1 01-30-2007 10:02 PM
Sql + Oracle Select If ???? smaida Programming 11 12-15-2004 08:13 PM
Bizarre SQL select query acid_kewpie Programming 6 01-20-2004 12:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration