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

Keeping Last 5 Characters of String from Displaying in Output 1

Status
Not open for further replies.

jcg6

Technical User
Feb 18, 2002
50
0
0
US
I would like to "hide" the last 5 characters of a field when it displays. I have done this in Access using the LEN function: User:Len(Primary_User - 5) - but that doesn't work in SQL.

Does anyone have a simple solution for me. Thanks for your help.
 
Try this

SELECT LEFT(Primary_user,len(Primary_user)- 5)
FROM TBLNAME


Sunil
 
That didn't seem to work - this is the error I received:

Server: Msg 536, Level 16, State 2, Line 1
Invalid length parameter passed to the substring function.
 
That is happening bcos some of the data in the fields doenst have length of 5. Try something like this

select
case When len(primary_user)> 4 Then LEFT(primary_user,len(primary_user)- 5) Else '' End
from TBLNAME


Sunil
 
Thank you so much - that did exactly what I needed it to!! [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top