Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

need to trim first 11 characters off a string in SQL

Tags:

sql

sql-server

Is there anyway to trim the first x amount of characters in a varchar? I am unable to do this using the left or right functions a well as other trimming methods. Will be doing this on standard MS-SQL. Thank you.

like image 708
njj56 Avatar asked Feb 02 '12 14:02

njj56


2 Answers

SELECT STUFF(SomeString,1,11,'')

(obligatory link)

like image 95
Martin Smith Avatar answered Oct 10 '22 04:10

Martin Smith


There are several ways of doing it. One of the simpler ones would be to use RIGHT and LEN combination:

select RIGHT(a.col, LEN(a.col)-11) from MyTable a
like image 33
Sergey Kalinichenko Avatar answered Oct 10 '22 05:10

Sergey Kalinichenko