Solved

Access SQL qurey error

Posted on 2010-11-19
9
263 Views
Last Modified: 2012-05-10
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
Comment
Question by:ubsmail
  • 5
  • 4
9 Comments
 
LVL 13

Expert Comment

by:Torrwin
ID: 34175425
Try:

SELECT LEFT(Products.Number, InStr(1, Products.Number, '.'))
FROM Products
0
 
LVL 13

Expert Comment

by:Torrwin
ID: 34175445
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
 

Author Comment

by:ubsmail
ID: 34175465
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
 
LVL 13

Expert Comment

by:Torrwin
ID: 34175660
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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

Author Comment

by:ubsmail
ID: 34175759
Thanks Torrwin

I got this error:

Syntax error (missing operator) in qury experrsion 'CASE WHEN (Instr(1, Products.Number, '.') >0)........
0
 
LVL 13

Expert Comment

by:Torrwin
ID: 34175853
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
 

Author Comment

by:ubsmail
ID: 34175869
Same error accesss is picky
0
 
LVL 13

Accepted Solution

by:
Torrwin earned 500 total points
ID: 34175953
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
 

Author Closing Comment

by:ubsmail
ID: 34176139
Thanks!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now