Tuesday, July 3, 2007

sp_rename @ SQL Server 2005

It Changes the name of a user-created object in the current database. This object can be a table, index, column, alias data type, or Microsoft .NET Framework common language runtime (CLR) user-defined type.

Syntax:

sp_rename @ObjectName, @ObjectNewName, @ObjectType

WHERE:

@ObjectName: is the name of the user object etc.
@ObjectNewName:
is the new name of the user object. It has no defaults.
@ObjectType:
defines the type of the user object to be renamed. The following types are supported:
  • A column
  • A database
  • An Index
  • UserDataType ( Alias type, objects created using CREATE statement and CLR user defined types)

1 comment:

Jacob Sebastian said...

Note that it is not a good idea to rename stored procedures, functions etc. It is far more safer to drop the procedure/function and recreate them with the new definition. See this: http://www.sqlserverandxml.com/2008/09/be-careful-when-renaming.html