Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net Rename a SQL table

Hi

What VB.net code would I use to rename a SQL table

Thanks
Avatar of arnold
arnold
Flag of United States of America image

You have to make sure there are constraints,indexes, etc. that could prevent,

You would issue "alter table tablename rename to new tablename"
Alternatively, you could create a new table using the old ones schema, copy the data, and drop the old table.

Or use the stored procedure, sp_rename old name,newname, table
ASKER CERTIFIED SOLUTION
Avatar of Ali HND
Ali HND
Flag of Iran, Islamic Republic of image

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 Murray Brown

ASKER

Great! Thanks very much
NOTE that you have to check for errors, as constraints, foreign keys, indexes, etc. could through an error denying the change. To change the table name in such circumstances, index, statistics, constraints, triggers have to be dropped.