How to replace blank (null ) values with 0 for all

2020-02-25 05:25发布

MS Access: How to replace blank (null ) values with 0 for all records?

I guess it has to be done using SQL. I can use Find and Replace to replace 0 with blank, but not the other way around (won't "find" a blank, even if I enter [Ctrl-Spacebar] which inserts a space.

So I guess I need to do SQL where I find null values for MyField, then replace all of them with 0.

11条回答
看我几分像从前
2楼-- · 2020-02-25 05:47

Better solution is to use NZ (null to zero) function during generating table => NZ([ColumnName]) It comes 0 where is "null" in ColumnName.

查看更多
劳资没心,怎么记你
3楼-- · 2020-02-25 05:52
UPDATE YourTable SET MyField = 0 WHERE MyField IS NULL

works in most SQL dialects. I don't use Access, but that should get you started.

查看更多
家丑人穷心不美
4楼-- · 2020-02-25 05:55

I just had this same problem, and I ended up finding the simplest solution which works for my needs. In the table properties, I set the default value to 0 for the fields that I don't want to show nulls. Super easy.

查看更多
相关推荐>>
5楼-- · 2020-02-25 05:57

Using find and replace will work if you type "null" in the find and put a zero in the replace...you will be warned that this cannot be undone.

查看更多
祖国的老花朵
6楼-- · 2020-02-25 06:01

I used a two step process to change rows with "blank" values to "Null" values as place holders.

UPDATE [TableName] SET [TableName].[ColumnName] = "0"
WHERE ((([TableName].[ColumnName])=""));

UPDATE [TableName] SET [TableName].[ColumnName] = "Null"
WHERE ((([TableName].[ColumnName])="0"));
查看更多
登录 后发表回答