Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL Argument data type decimal is invalid for argument 1 of substring function.

Hi

I am trying to list all records where the number starts with a 2 but I get the error

Argument data type decimal is invalid for argument 1 of substring function.

I know that the following syntax doesn't work. What would the correct syntax be?

Select * From MARA_MBEW Where SubString([Total Stock],1, 1) = 2
ASKER CERTIFIED SOLUTION
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Lokesh B R
Lokesh B R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Use LEFT function:
Select * From MARA_MBEW Where LEFT([Total Stock],1) ='2'

Open in new window

Lokesh is correct, the best style for performance is:

Where [Total Stock] Like '2%'
Avatar of Murray Brown

ASKER

Thanks