tags:

views:

68

answers:

2

I need to update a group of cells by inserting the same two characters into all of them, but I'm just drawing a blank on how to do this. Could someone point me in the right direction?

Old Cells
HI.1
HI.2
HII.1

New Cells
H08I.1
H08I.2
H08II.1

+2  A: 

If all your cells look like that:

update cells
set cell = Replace(cell,'H','H08');

(But note that Replace doesn't care where the 'H' appears).

Note: I am assumign we are talking about SQL and tables here - maybe a "cell" is something else?

Tony Andrews
By cells I meant cells within a table. Although I didn't specify, there are multiple H's, so Michael's answer will work better for my needs. Thanks for the response.
craigmj
+3  A: 
UPDATE Cells SET Cell = LEFT(Cell, 1) + '08' + SUBSTRING(Cell, 1, LEN(Cell)-1)
Michael Haren
This assumes you want to insert after the first character (but doesn't assume it's an "H").
Michael Haren
If it IS always an "H", and the only "H" in the cell, then @Tony Andrews's answer is good.
Michael Haren