[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

SQL IIf Then Statement

I have a large table containing one field "Unit" that 50% of the units are 4-digit numbers and the other 50% are 5-digit numbers.   I need to add a zero to the left of the 4-digit numbers but do not want to add the zero to the 5-digit numbers. How would I accomplish this?  I am working in MS Access 97 but can use the SQL feature for updating this table.
0
deer777
Asked:
deer777
1 Solution
 
deer777Author Commented:
Tried this in the Update mode of the Access query but it doesn't work

IIf (Len[Unit] = 4, "0"+[Unit])
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
IIf (Len[Unit] = 4, "0" & [Unit], [Unit])
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now