468,236 Members | 1,957 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,236 developers. It's quick & easy.

Reg sql query

I have a SQL Table I am trying to update...I would like to add 'ABC' to the START of every value in a perticular column.

Can any one help me..

--
Sharique
Sep 30 '08 #1
4 1280
before:
ANZAED12M
ANZAED1M
ANZAED1M
ANZAED2M
ANZAED2M
ANZAED3M
ANZAED3M
ANZAED6M
ANZAED6M
ANZAED9M


after:
OOOAED12M
OOOAED12M
OOOAED1M
OOOAED1M
OOOAED2M
OOOAED2M
OOOAED3M
OOOAED3M
OOOAED6M
OOOAED6M
OOOAED9M
OOOAED9M


query:

UPDATE table_name SET column=substring(column,1,start-1) || 'values' || substring(column,4,length of column) WHERE substring(column,1,3) = 'values'

UPDATE table_name SET ric=substring(ric,1,0) || 'OOO' || substring(ric,4,30) WHERE substring(ric,1,3) = 'ANZ'
Sep 30 '08 #2
ck9663
2,878 Expert 2GB
Your query did not add the string but replace it. I believe this would be more efficient:

Expand|Select|Wrap|Line Numbers
  1. UPDATE YourTable
  2. set = replace(yourcolumn,'ANZ','OOO')
  3. where yourcolulmn like 'ANZ%'
  4.  
-- CK
Sep 30 '08 #3
deric
92
Try this:
Expand|Select|Wrap|Line Numbers
  1. UPDATE TableName SET ColumnName = 'ABC' + ColumnName 
You can research more about SQL scripting here.
Sep 30 '08 #4
deric
92
Try this:
Expand|Select|Wrap|Line Numbers
  1. UPDATE TableName SET ColumnName = 'ABC' + ColumnName 
You can research more about SQL scripting here.
Oops.. this is very late. hehe
Sep 30 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by jaysonsch | last post: by
9 posts views Thread by netpurpose | last post: by
3 posts views Thread by Harvey | last post: by
4 posts views Thread by Diamondback | last post: by
14 posts views Thread by Dave Thomas | last post: by
4 posts views Thread by Stan | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.