SQL Calculation involving NULL in Access
I am using an INSERT INTO .... SELECT .... type SQL command, which works
fine from a query within Access, but doesn't work when I try to execute is
through an OleDBCommand in my VB2005 project.
The problem is that the value for one of the fields is calculated from an
aggregate function which may be Null. I got around this in Access using the
Nz function something like this:
.... SELECT NZ(Max(Field))+1 ...
but I soon found that Nz cannot be used via OleDb.
For SQL Server I think I can use something like ISNull(Max(Field),0) but
this doesn't seem to work with Access.
I found a website that suggests using something like this instead of
Nz(Value):
IIF(ISNull(Value),0,Value)
but I am concerned that if I replace Value with Max(Field) this will
evalulate the Max function twice, and have an impact on performance. Is this
a problem? and if so, is there a better way to do this?
TIA
Phil
Date:Wed, 22 Aug 2007 16:29:54 +0100
Author:
|