Divide by zero in Stored procedure (MS Access project)

  • Thread starter Thread starter lemes_m
  • Start date Start date
L

lemes_m

What I can do to solve this problem? (IIF doesn't work in Stored
procedures)
 
It's impossible to say what's the best way of solving your particular
problem since you haven't given us any clues about what code you actually
have in your stored proc. However, the SQL Server CASE function is the
usual answer when you need an "equivalent" to the Access Iif function (it
isn't exactly an equivalent, but you can do the same sort of things with
it).
 
You may want to look at the Switch function or the Select Case statement.
 
He's doing this in a Stored Procedure, there is no Switch function nor
Select Case statement.
 
Baz je napisao/la:
It's impossible to say what's the best way of solving your particular
problem since you haven't given us any clues about what code you actually
have in your stored proc. However, the SQL Server CASE function is the
usual answer when you need an "equivalent" to the Access Iif function (it
isn't exactly an equivalent, but you can do the same sort of things with
it).

I need to solve the problem with 'divide by zero' and formula in MS
Access query grid for this is:
Expr1:IIF(Field2=0,0,Field1/Field2)

I would like to get same result but in SP.

Thanks in advance
 
CASE WHEN Field2 = 0 THEN 0 ELSE Field1/Field2 END

If you are going to do much in the way of stored procedures you are going to
need to get SQL Server Books Online, not sure if it is downloadable from
Microsoft's web site.
 
What I can do to solve this problem? (IIF doesn't work in Stored
procedures)

What kind of stored procedure do you mean? IIF does work in VBA.
 
A SQL Server stored procedure, what other kind is there? And no, VBA
functions cannot be used in stored procedures.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top