I have a column in a SQL table called ID (ex. 1234,12345). I want to add a "LM" to every record in that column: LM1234, LM12345, etc
We suppose that ID column has varchar/char/... or any other string related data type., so try this:
UPDATE [TABLE_NAME] SET [COL] = 'LM'+COL
Assuming that the id is a string, just do an update:
update t
set id = 'LM' + id;
If column is not a string, then you need to make it one first:
alter table t alter id varchar(255);
update t
set id = 'LM' + id;
Also, you could just add a computed column to do the calculation:
alter table t add lm_id as (concat('LM', column))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With