I need your help real quick.... I use SQL 2008 R2
I have this column that has this kind of data
1_kka
2_bge
3_kil
the column should have only the number which is
1
2
3
So how should i replace it by using replace and substring?
Thank you!!
I need your help real quick.... I use SQL 2008 R2
I have this column that has this kind of data
1_kka
2_bge
3_kil
the column should have only the number which is
1
2
3
So how should i replace it by using replace and substring?
Thank you!!
In MySQL, you can do this remarkably easily by just adding 0 tot he string:
select col + 0
from t
The + 0 treats the string as an integer, and it automatically converts any numbers at the beginning of the string into a number.
In other databases, something like this will work:
select cast(left(col, 1) as int)
from t
Assuming that the initial number has exactly one digit (as in the examples in your question).