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.
| Author |
Topic |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2006-08-02 : 14:48:43
|
| How to set cell to blank not <null> if there is no data? |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-08-02 : 15:02:26
|
when you say "cell" what do you mean? If you are referring to values in sql table:update <table> set <column> = '' where <pk> = <value> and <column> is null EDIT:This would only work on character based data. I'm sure you don't want to do this...erase this from your brain. Just use whatever tool your are using to display this data to change the presentation of the data.<endEDIT>My guess is that you don't want to update these values but rather change the display. What are you using to view your data?Be One with the OptimizerTG |
 |
|
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2006-08-02 : 15:48:31
|
| In fack, it is entire column. I like defaul to ' ', not <null>. Is it possible? So that I do not need update it from <null> to ' '. |
 |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2006-08-02 : 20:38:51
|
| Add a default constraint to the table. for example if the col name was NOTGONNABENULL and the Table name was SOMETABLE just use thisALTER TABLE SOMETABLE ALTER COLUMN NOTGONNABENULL NULL CONSTRAINT [DF_SOMETABLE_NOTGONNABENULL] DEFAULT ('') |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-08-02 : 21:24:05
|
| You should also change the column to be NOT NULL if you don't want it to be null.CODO ERGO SUM |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-08-03 : 04:47:01
|
| Don't want to start a flame-war! but I think there may be more to this empty-string v. NULL issue than just setting the column to empty-string.Personally I would prefer a column to be NULL, rather than defaulting to an empty string. The user can then physically enter a blank string if that is the valid data, but for all other instances the data will remain NULL and thus represent "unknown".For example, address line 5 may very well be empty, few addresses are that long. But what about a delivery address on an order?. a) there may be no delivery address (collect, or deliver-to-invoice-address) or b) the address may not be required when the record is first created. I would much prefer to have NULL in those circumstances, rather than empty-string, because I know that no-one has yet allocated an address - rather than that they have not yet got around to providing one, because when they do provide one it, or bits of it, may very well be blank.On the presentation side you can then treat NULL as EmptyString when you display it.We wrestled with this for quite a long time for our application, and decided that NULL was more useful than an empty string in handling "empty" cells/columns. Don't forget that "empty string" only works for "string" datatypes, so you can't have empty-string for date, numeric, bit, etc. datatypes; so embarrassing NULL might be a better step forwards in your design.Kristen |
 |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2006-08-03 : 09:03:58
|
| Agreed. But you will probably still get quote of the week on dbdebunk. |
 |
|
|
|
|
|
|
|