Anjana Anjana - 1 month ago 14
SQL Question

SQL Query update for integer datatype

Need a help with SQL
I have a table with EmployeeID as below

11
22
1
55
2


I wanted to trim the last digits of all the rows and get the output as

1
2
1
5
2

Answer

USE this one

 CASE WHEN LEN(ColumnName)>1 THEN LEFT(ColumnName, LEN(ColumnName)-1) ELSE        ColumnName END