1 Version 4.0 -- 1/15/89 sp_rename
______________________________________________________________________
NAME: sp_rename
FUNCTION:
Changes the name of a user-created object in the current data-
base.
SYNTAX:
sp_rename objname, newname
EXAMPLES:
1) sp_rename titles, books
sp_rename Version 4.0 -- 1/15/89 2
______________________________________________________________________
Renames the titles table to books.
2) sp_rename "books.title", name
Renames the title column in the books table to name.
3) sp_rename tid, bookid
Renames the user-defined datatype tid to bookid.
PARAMETERS:
objname - is the original name of the user object (table, view,
column, stored procedure, trigger, default, or rule) or data-
type. If the object to be renamed is a column in a table,
objname must be in the form "table.column".
You can rename an object in the current database only, and
3 Version 4.0 -- 1/15/89 sp_rename
______________________________________________________________________
only if you own it. This rule holds for the Database Owner
and System Administrator as well as for other users.
newname - is the new name of the object or datatype. Names of
objects and datatypes must follow the rules for identifiers.
COMMENTS:
o Executing sp_rename changes the name of a user-created object
or datatype.
o The names of system objects and system datatypes cannot be
changed.
o You can change the name of an object or datatype in the current
database only.
o A user may change the names only of those objects he or she
owns. The Database Owner may change the name of any user's
objects.
sp_rename Version 4.0 -- 1/15/89 4
______________________________________________________________________
WARNING _______________________________________________________________
| |
| Procedures, triggers, and views that depend on an object whose |
| name has been changed work fine until they are recompiled. How- |
| ever, recompilation takes place for many reasons and without |
| notification to the user. When the procedure, trigger, or view |
| is recompiled by SQL Server, it will no longer work. The user |
| must change its text to reflect the new name of the object on |
| which it depends. The safest course is to change the defini- |
| tions of any dependent objects when you execute sp_rename. You |
| can find dependent objects with sp_depends. |
|______________________________________________________________________|
5 Version 4.0 -- 1/15/89 sp_rename
______________________________________________________________________
MESSAGES:
The name supplied for the objname parameter included a reference
to a database. The object must be in the current database.
The specified object is not an object or user-defined datatype.
No column of the specified name exists in the specified table, or
you don't own the table.
The specified column name has been renamed to newname.
The specified user-defined datatype has been renamed to newname.
The specified object has been renamed to newname.
Note that if the object is a table or view, names beginning with
'#' are not allowed.
PERMISSIONS:
Execute permission to object owners for their own objects. Exe-
cute permission to Database Owner for all objects.
sp_rename Version 4.0 -- 1/15/89 6
______________________________________________________________________
TABLES USED:
syscolumns, sysobjects, systypes
SEE ALSO:
sp_addtype, sp_depends, sp_renamedb, ALTER TABLE, CREATE DEFAULT,
CREATE PROCedure, CREATE RULE, CREATE TABLE, CREATE TRIGGER,
CREATE VIEW