LinuxQuestions.org
Help answer threads with 0 replies.
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, 02: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, 02:31 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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, 08:18 PM   #3
paulsm4
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, 09:24 PM   #4
BenCollver
Rogue Class
 
Registered: Sep 2006
Location: OR, USA
Distribution: Slackware 14.1
Posts: 164

Rep: Reputation: 57
I like coalesce.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 09:11 PM
SQL question - checking for NULL? BrianK Programming 2 04-13-2007 11:11 AM
SQL SELECT Group by 2 conditions MicahCarrick Programming 1 01-30-2007 11:02 PM
Sql + Oracle Select If ???? smaida Programming 11 12-15-2004 09:13 PM
Bizarre SQL select query acid_kewpie Programming 6 01-20-2004 01:47 PM


All times are GMT -5. The time now is 01:13 PM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration