SQL Substring to end of string

I would like to do a SUBSTRING statement in SQL that gives me the result of the 2nd character position to the end of the string.  However when I try to execute the statement

SELECT SUBSTRING (field1, 2)

It throws an error and places a comma after the "2" like it expects another parameter
zintechAsked:
Who is Participating?
 
Rajkumar GsConnect With a Mentor Software EngineerCommented:
Same - another example
DECLARE @INPUT VARCHAR(100)
SET @INPUT = 'www.experts-exchange.com'
SELECT SUBSTRING(@INPUT, 2, LEN(@INPUT))
-- ww.experts-exchange.com

Open in new window

0
 
Rajkumar GsSoftware EngineerCommented:
DECLARE @INPUT VARCHAR(20)
SET @INPUT = 'RAJKUMAR'
SELECT SUBSTRING(@INPUT, 2, LEN(@INPUT))

-- AJKUMAR

Open in new window

0
 
CluskittCommented:
It need a parameter of length (how many chars you want to show). In theory, the best practice would be LEN-1, but you can just overload it and it will return till the end.
0
 
NorieVBA ExpertCommented:
Do you mean the 2nd last character in the string?

SELECT LEFT(RIGHT('TheString',2),1)

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.