views:

8

answers:

3

Hi I want to insert char (A) in second index where code start with 's'

Input
s1
s2
s34

Require output
sA1
sA2
sA34

Update T1
set code = ??
where code like 's%'

alt text

A: 

Try this:

UPDATE myTable
SET  myColumn = 'sA' + RIGHT(myColumn, LEN(myColumn)-1)
WHERE LEFT(LOWER(myColumn), 1) = 's'
p.campbell
all colums set to sA where condition satisfied
NETQuestion
@NETQuestion: feel free to give upvotes to all who helped answer your question!
p.campbell
A: 
Update T1
set code = 'sA' + SUBSTRING(code, 2, LEN(code)-1 )
where code like 's%'
x2
+2  A: 
Update MyTable
Set Code = Stuff(Code, 2, 0, 'A')
Where Code Like 's%'
Thomas
+1 for `STUFF` !
p.campbell
simple and better
NETQuestion