Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Substring - Remove Last Character(s)

I have a SQL query that brings back 2 columns of data both of TYPE TEXT.

What i am trying to do is:

UPDATE [DBNAME}
SET [3 15] = SUBSTR([3 15], -1))
where [3 15] LIKE  '%;'

Where [3 15] is the column name, i would like to pull the data from that column which has ends in a ';' and then remove the trailing ';'

This would be easy if the column type was string but its not.

Running on a: Microsoft SQL Server 2005 - Developer Edition

like image 994
Lemex Avatar asked Oct 20 '25 08:10

Lemex


1 Answers

Hope this sql will help you

SELECT LEFT('CHAMLY', LENGTH('CHAMLY') -1);

for further reading use http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

like image 168
Chamly Idunil Avatar answered Oct 22 '25 22:10

Chamly Idunil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!