Disclaimer:
I am still learning SQL so I apologize if my question comes off as amateur-ish or is otherwise a very simple answer. I have no formal training. I am teaching myself.
The title may be a bit confusing, as I’m not entirely sure how to word this for a title.
Basically, I want to convert a column in a table thats currently VARCHAR into an INT. The column contains only numbers formatted as such:
00001
00005
02150
These are essentially ID’s which will be appended to a Name column later for other purposes. If its necessary to do so, I’d also like to know how to convert the end result INT to VARCHAR for the append portion.
Here’s what I have right now:
SELECT CONVERT(INT, LocNo)
It returns the results I expect but I think I need to somehow update the existing LocNo column or otherwise put it in a new column for forward use.
What should I do to achieve this?
Try this
If you want new column, add new column to table and then do update
When Selecting and appending to varchar you can do
If you want
0'sback inLocNo/newColthen