Remove last character in T-SQL string

1146650 pts.
Tags:
SQL
T-SQL
Is it possible to remove the last character in a T-SQL string? So for example, I have this:
STRING
I want to have this:
STRIN
Thanks!
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • ToddN2000
    Sounds like a homework question. Post your code and let us take a look. We can help you fix you problem if we know what it is. Show us you at least tried. It only gets harder from here on out if you can't get the basics down.
    133,800 pointsBadges:
    report
  • rekha41
    DECLARE @String VARCHAR(100)
    SET @String = 'TEST STRING'

    -- Chop off the end character
    SET @String = Case @String when null then null else (case LEN(@String) when 0 then @String else LEFT(@String, LEN(@String) - 1) end ) end

    SELECT @String

    140 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: