SQL Rename Table - How to Rename a Table in SQL
Demo wikitechydatabase
- Below is a selection from the wikitechytable table used in the examples:
- In Microsoft SQL Server (MSSQL), you can rename a table using the sp_rename system stored procedure.
Syntax
EXEC sp_rename 'old_table_name', 'new_table_name';
- Replace old_table_name with the current name of the table you want to rename, and new_table_name with the new name you want to assign to the table.
- In this example, the table named "wikitechytable" is renamed to "wtable". Make sure you have the necessary permissions to execute the sp_rename procedure, and be aware that renaming a table may also affect any associated objects like views, triggers, or stored procedures that reference the table. You may need to update these objects accordingly after renaming the table.