I would like to remove the last number or 1 in this sequence:
0495747500000049908275289000100040000000041
How do I do in sql server?
I would like to remove the last number or 1 in this sequence:
0495747500000049908275289000100040000000041
How do I do in sql server?
You can combine the left()
function to get all characters starting from the left to the limit that is set by len()
(which returns the string size) -1
. Something like:
select left('0495747500000049908275289000100040000000041',
len('0495747500000049908275289000100040000000041') - 1)
Or
select left(campo, len(campo) - 1)
You can use the RIGHT
function, it would look like this:
SELECT RIGHT(CAMPO, 1)
If your field is a number need convert to varchar:
SELECT RIGHT(CAST(CAMPO AS VARCHAR(50)))
Do not forget to change the size of Varchar
to your requirement.
I hope I have helped.
You can use either LEFT or SUBSTRING.
DECLARE @numero VARCHAR(MAX)
SET @numero = '0495747500000049908275289000100040000000041'
SELECT LEFT(@numero, LEN(@numero) - 1) AS 'LEFT', SUBSTRING(@numero, 0, LEN(@numero)) AS 'SUBSTRING';
Returns the left part of a character string with the number of specified characters.
Returns part of a character, binary, text, or image in SQL Server.