Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting Characters in a Query

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have an id number 1234567 where 7 is the "check" digit. I need to run a query that has the digits "123456" in one field, and 7 in another. I can get the 7 out, but due to varying id lengths, I can't always get the first digits out. I've tried mixing functions like -- left([id], len([id])- 1) but that doesn't seem to work. Any ideas?
 
Try:

SELECT LEFT(CSTR([ID]), 1, LEN(CSTR([ID])) - 1) AS LeftPart,
RIGHT(CSTR([ID]), 1, 1) AS RightPart
FROM MyTable

Hope that helps... Terry M. Hoey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top