question

Cricket132 avatar image
Cricket132 asked

How do I remove the first 12 characters AND drop the last character in a string?

my table has the following:

IDLogin1abcdefghijk\smith02abcdefghijk\roberts03abcdefghijk\canton04abcdefghijk\mortenson05abcdefghijk\anderson0

I need to see only the name, without the 0.

This following removes the first 12 characters:

select substring(loginid, 12, 11) from DBSec;

and this removes the last character

select left([LoginID], len([LoginID])-1) from DBSec;

HOW DO I COMBINE THE BOTH to get, for example:

IDNo Column Name1smith2roberts3canton4mortenson5anderson
substringleft
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

This is my very first post so apologies if it in not in the correct format.

0 Likes 0 ·

1 Answer

·
Kev Riley avatar image
Kev Riley answered

simply combine the two:

substring(left([LoginID], len([LoginID])-1), 13, len(left([LoginID], len([LoginID])-1)))
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.