Click here to Skip to main content
15,894,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All
I have requirement like below
#CNAAB
#CNAAC
#CNADD

So if I put #CNA in the change from field, and CNB in the change to field, the new alphas would be:
CNBAB
CNBAC
CNBDD
that is replace first four character(#CNA)by three character(CNB)
how should I write the query for that? Please help.
Posted

1 solution

SQL
UPDATE tablename
SET fieldname = replace(fieldname, '#CNA', 'CNB')
 
Share this answer
 
v2
Comments
IndrajitDasgupat 9-Mar-11 6:23am    
replace(fieldname, '#CNA', 'CNB') in this scenario it is not always #CNA it may be different so I have to select field name and in the place CNB it may be different character so I have to pass it from front end, then what will be the function?
Prerak Patel 9-Mar-11 6:28am    
I think it's not hard to pass them as parameters. Do work on it, and make a function with those two parameters.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900