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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last Character of A Field

Status
Not open for further replies.

dbinfoweb

Technical User
Nov 20, 2001
59
US
I have a field with char type and 17 in length and user entered various length of data in it. Some are 5, 10, 12, 14 or 15. But the last character is the one in interest. I am just wondering how I can run a query to get the last character of that field. I have tried substring, char_length with no success. Any help will be appreciated.

Thanks in advance.
 
If your table is having char data type, then it may not return what you are expecting. Probably, you need to convert your data type to varchar and then use right function to get desired result.

Following sql statement may help....

select
right(convert(varchar(17),col_name),1)
from
table_name


Regards,
Rajdeep
 
Awesome! it works! thanks so much for helping out. Your assistance is very much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top