Home

Renaming a Table

 

Introduction

To rename a table using code, execute the sp_rename stored procedure using the following formula:

sp_rename ExistingTableName, TableNewName;

Here is an example:

sp_rename 'StaffMembers', 'Employees';
GO

In this case, the interpreter would look for a table named StaffMembers in the current or selected database. If it finds it, it would rename it Employees. If the table doesn't exist, you would receive an error.

 
 

Home Copyright © 2007-2008 FunctionX, Inc.