Wheneverwe have to change anything in the database we mostlyuse Management Studio and do the changes. In this article I amgoing to demonstrate the use of "sp_rename" stored procedure. It isused to rename any user created objects in SQL Server.
Whenwe say re name then this object can be anything, it can be table, column,index, alias, datatype or any user defined data type in Microsoft .NETFramework CLR. But using this there can several issues like, ourexisting scripts and stored procedure will fail to run as it will throw anerror for used object(s) as they got renamed. It is advised to use this storedprocedure for renaming the stored procedures, triggers, user-defined functionsor views, rather than dropping and recreating that object.
old_object_name - Thisis a qualified or unqualified name of the user created object. If we want torename a column of a table then it should be specifiedas 'table.column' or 'schema.table.column' andsame goes for index. It does not have any default value, so we have to specifysome value in the quotation.
new_object_name - Itsa new name of the object which should being single part and must follow therules for identifiers. It also does have any default value.
object_type -This is a type of object being renamed.