sql - How to update a specific characters of column value for all tables in a database -


i trying update specific characters of column value tables in database in sql server 2008. have _workgroupname column in tables , want change characters in _workgroupname in tables of database.

sample data _workgroupname column

cowai1 cowai2 pmwai1 pmwai2 

need results

coxxx1 coxxx2 pmxxx1 pmxxx2 

i want change wai xxx. , tying below sql.

select 'update ' + t.table_schema + '.' + t.table_name + '  set _workgroupname = n''xxx'   information_schema.tables t  inner join information_schema.columns c on  t.table_name = c.table_name , c.column_name ='_workgroupname'  t.table_type = 'base table' order t.table_schema, t.table_name 

but problem above statement updating column value xxx, want change wai xxx. how achieve this.

edit :

in tables _workgroupname name contains data , wai comes after 2 characters. , after wai number can number.

for example

aswai1500 wewai900000 aswai96 ddwai11111 

try this

select 'update ' + t.table_schema + '.' + t.table_name + '  set _workgroupname = replace(_workgroupname,''wai'',''xxx'')'   information_schema.tables t  inner join information_schema.columns c on  t.table_name = c.table_name , c.column_name ='_workgroupname'  t.table_type = 'base table' order t.table_schema, t.table_name 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -