Avatar of Murray Brown
Murray Brown
Flag 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
Visual Basic.NETMicrosoft SQL Server

Avatar of undefined
Last Comment
arnold

8/22/2022 - Mon
arnold

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
Ali HND

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Murray Brown

ASKER
Great! Thanks very much
arnold

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes