tags:

views:

154

answers:

3

I have an access table which has some cells as blank ( no data ) in a particular column.

how i write an sql query to replace a blank cell with any text in access 2007 column

any help appreciated.

i have already tried the sql query

update tableA set colA = 'abc' where ISNULL(colA);

It updates 0 rows.

+1  A: 
Update Table
Set [ColumnName] = "my random text"
Where Len([ColumnName]) = 0 OR [ColumnName] Is Null

This will account for situations where the cell value is an empty string or if it is null. If you are trying update one column from another you can do:

Update Table
Set [ColumnName] = [MyOtherColumnName]
Where Len([ColumnName]) = 0 OR [ColumnName] Is Null
Thomas
Remou
Or in Access lingo you can use Nz which is faster than the concatenation: Where Len(Trim(Nz([ColumnName],""))) > 0. Not that it makes much difference. Once you decide to put a function in the where clause you have somewhat accepted that speed isn't the overriding issue.
Thomas
Just to follow on all of this, if you've got Allow ZLS turned on (as is the default starting with A2003, unfortunately), it should be turned off. This is a great annoyance to me, since it's such an awful idea. It even gets changed for some converted databases (A97 to A2003, for instance).
David-W-Fenton
@David-W-Fenton - OMG, yes the ZLS option was and is one of the many evil options in Access. The only thing I assume with Access is that I cannot make many assumptions.
Thomas
+1  A: 

Im pretty sure its

update tableA set colA='abc' where colA is null
Jason Jong
+3  A: 

Try this:

update tableA set colA = 'abc' where colA IS NULL;
Jojo Sardez