Go Premium for a chance to win a PS4. Enter to Win

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

Access SQL qurey error

Hello I get this error on the below select statment. Your help is apperciated in advance.

Undefined function 'chatindex' in expression

select  LEFT(products.number, charindex('.',products.number)) from products
0
ubsmail
Asked:
ubsmail
  • 5
  • 4
1 Solution
 
TorrwinCommented:
Try:

SELECT LEFT(Products.Number, InStr(1, Products.Number, '.'))
FROM Products
0
 
TorrwinCommented:
Actually, that may include the period in the selection, so you may need to add a -1 to the position:

SELECT LEFT(Products.Number, (InStr(1, Products.Number, '.')-1))
FROM Products
0
 
ubsmailAuthor Commented:
Looks good any way to handel the error if it does not have a "."

Expr1000
#Error
1ABMJK0005
1ABMJK0005
1ABMJK0005
1ABMJK0005
#Error
1ABMJK0006
1ABMJK0006
1ABMJK0006
1ABMJK0006
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
TorrwinCommented:
You could use a CASE statement, something like:

SELECT CASE WHEN (InStr(1, Products.Number, '.') > 0) THEN LEFT(Products.Number, (InStr(1, Products.Number, '.')-1)) ELSE Products.Number) END
0
 
ubsmailAuthor Commented:
Thanks Torrwin

I got this error:

Syntax error (missing operator) in qury experrsion 'CASE WHEN (Instr(1, Products.Number, '.') >0)........
0
 
TorrwinCommented:
Oops, looks like a missing parenthesis:

SELECT CASE WHEN ((InStr(1, Products.Number, '.') > 0) THEN LEFT(Products.Number, (InStr(1, Products.Number, '.')-1)) ELSE Products.Number) END
0
 
ubsmailAuthor Commented:
Same error accesss is picky
0
 
TorrwinCommented:
If you're running it in Access,  you could use the IIF function instead:

SELECT IIF(InStr(1, Products.Number, '.') > 0, LEFT(Products.Number, (InStr(1, Products.Number, '.')-1)), Products.Number)
FROM Products
0
 
ubsmailAuthor Commented:
Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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