Pages

Monday, March 10, 2014

How to Rename a Table in SQL Server 2008

SQL Server tables are the objects that store all of your information in the database. The table is given a name when you program it into the database. If you decide to change the table in the future, you can change it using Structured Query Language (SQL) commands provided by the SQL Server console application. The table's name changes immediately after the "sp_rename" stored procedure is executed.

Instructions

    1

    Click the SQL Server's "Start" button and click "All Programs." Click "SQL Server" in the program group list and then click "SQL Server Management Console," which opens the interface console for your database.

    2

    Right-click the database on the left side of the window and select "New Query." This opens a text editor for your SQL statements.

    3

    Type the following into the text editor:

    EXEC sp_rename 'Customer', 'Cust'

    "Customer" is the original name of your table and "Cust" is the name to which you want to change it.

    4

    Press the "F5" key. This executes the SQL statement. Notice the table's name change on the left side of the window in the list of tables for your database.

0 comments:

Post a Comment