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
 NULL value?

Author  Topic 

kumar.sqldba
Starting Member

6 Posts

Posted - 2007-08-13 : 13:45:16

Hi All
How do u make sure that a query does not return a null value?

Thanks in Advance..

chrisrock
Starting Member

12 Posts

Posted - 2007-08-13 : 13:46:16
Depends on what you're doing but look at the isnull function in sql. http://www.sqlteam.com/article/using-isnull

select isnull(your_column_value, '') from your_table

This will replace the null value with an empty string.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-14 : 01:45:04
quote:
Originally posted by kumar.sqldba


Hi All
How do u make sure that a query does not return a null value?

Thanks in Advance..


It depends on what you want to show in place of NULL

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

gator8869
Starting Member

37 Posts

Posted - 2007-08-23 : 19:20:57

MR1NEW MR2NEW (No Column Name)
159-08-03 NULL 000-00-00
137-03-04 NULL 000-00-00
095-11-02 NULL 000-00-00
079-06-91 NULL 000-00-00
050-08-97 NULL 000-00-00
037-12-93 NULL 000-00-00
061-01-04 NULL 000-00-00
186-05-04 NULL 000-00-00
062-03-03 NULL 000-00-00
120-06-04 NULL 000-00-00
137-07-03 NULL 000-00-00
113-11-70 NULL 000-00-00
072-07-04 NULL 000-00-00
229-03-98 NULL 000-00-00
034-09-78 226-11-76 2261176
229-03-98 NULL 000-00-00
226-11-76 NULL 000-00-00
138-06-04 NULL 000-00-00

I would like to replace the NULL in MR2 With 000-00-00, and leave to not nulls

Jeff
Go to Top of Page

Zoroaster
Aged Yak Warrior

702 Posts

Posted - 2007-08-23 : 19:32:33
In your case, something like
SELECT MR1NEW, isnull(MR2NEW, '000-00-00')

For example, although I am not sure what your actual query was.

-Z
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-23 : 19:32:47
quote:
Originally posted by gator8869


MR1NEW MR2NEW (No Column Name)
159-08-03 NULL 000-00-00
137-03-04 NULL 000-00-00
095-11-02 NULL 000-00-00
079-06-91 NULL 000-00-00
050-08-97 NULL 000-00-00
037-12-93 NULL 000-00-00
061-01-04 NULL 000-00-00
186-05-04 NULL 000-00-00
062-03-03 NULL 000-00-00
120-06-04 NULL 000-00-00
137-07-03 NULL 000-00-00
113-11-70 NULL 000-00-00
072-07-04 NULL 000-00-00
229-03-98 NULL 000-00-00
034-09-78 226-11-76 2261176
229-03-98 NULL 000-00-00
226-11-76 NULL 000-00-00
138-06-04 NULL 000-00-00

I would like to replace the NULL in MR2 With 000-00-00, and leave to not nulls

Jeff




Stealing someone else's thread?

Your question has been answered here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=88348

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -