2

This query runs in Access 2013 but I need it converted to SQL Server 2008. The issue is that the INSTR() function does not exist in SQL Server and the query references the field generated in same query EXPR1.

How would this be changed over to SQL Server 2008?

SELECT PartID, Description, Service, 
InStr(1,[Description]," ") AS Expr1, 
Left([Description],[Expr1]) AS part
FROM TI
WHERE (((PartID) Is Not Null) AND ((Service)="JTP"));

1 Answer 1

3

InStr is pretty similar to CHARINDEX. So, your query can be written as:

SELECT  PartID, 
        [Description], 
        [Service], 
        CHARINDEX(' ',[Description]) Expr1,
        LEFT([Description],CHARINDEX(' ',[Description])) Part
FROM TI
WHERE PartID IS NOT NULL 
AND [Service] = 'JTP';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.