Link to home
Start Free TrialLog in
Avatar of Scott Fell
Scott FellFlag for United States of America

asked on

Mass rename SQL tables

I have inherited a db with tables named like

dbo.xyz_aaaa
dbo.xyz_bbb
dbo.abc_cccc
dbo.abc_dddd
dbo.eeee
dbo.ffff

Everything to the right of the underscore is unique and I want to end up with

dbo.aaaa
dbo.bbb
dbo.cccc
dbo.dddd
dbo.eeee
dbo.ffff

Is there a way to use sql server to mass update dbo.xyz_aaaa to dbo.aaaa including any  Views or Stored procedures.   Or do I just use the generate scripts function, use the editor to do to a find and replace, then recreate?
SOLUTION
Avatar of BlueYonder
BlueYonder

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Scott Fell

ASKER

Thank you.  What about the find and replace for the table names in views and stored procedures?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, I got it done.  For the views and stored procs I just generated the script and did a find and replace.
You are Welcome