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
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Display Blank instead of Null

Author  Topic 

ncurran217
Starting Member

23 Posts

Posted - 2012-07-31 : 09:27:04
I want to know if it is possible to display a blank field instead of Null. I have name fields and when I imported them it was a blank field and now it shows Null in that field and if I export a certain names for a mailing list, I get Bob Null. Which is incorrect. Let me know if this is possible. Thanks!

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-07-31 : 09:45:17
coalesce(mycol,'')


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

ncurran217
Starting Member

23 Posts

Posted - 2012-07-31 : 09:53:10
Ok, so is there a way to just completely delete the Null out of the field so I do not have to put that in my queries every time?
Go to Top of Page

ncurran217
Starting Member

23 Posts

Posted - 2012-08-01 : 09:08:33
bump
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-08-01 : 09:10:29
[code]
update yourtable
set the_column = ''
where the_column is null
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2012-08-01 : 09:14:35
you probably don't want to do that.

A NULL value is a missing or undefined value -- in set theory it's special. In this case it is correct in that the null value represents that you don't know the surname for that person.

You could UPDATE the table to remove the NULLS if you wanted to

UPDATE t SET
t.[Column] = ''
FROM <Thet Table> AS t
WHERE t.[Column] IS NULL

But you'd probably have to end up adding a default constraint to the column and specifying that the value should not be NULL.

If you have declared columns as allowing NULLS then you will have to deal with the possibility that they can contain NULLS.

Transact Charlie
Msg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
http://nosqlsolution.blogspot.co.uk/
Go to Top of Page

ncurran217
Starting Member

23 Posts

Posted - 2012-08-01 : 09:15:56
Ok thank you!
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2012-08-01 : 09:22:38
or the other thing you could do is implement a view over the data and write your ISNULL(X, Y) statements there.

Then simply query the view in future.

Transact Charlie
Msg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION.
http://nosqlsolution.blogspot.co.uk/
Go to Top of Page
   

- Advertisement -