Rakesh Singh
What command do we use to rename a db, a table and a column?
By Rakesh Singh in SQL Server on Apr 24 2014
  • Manju lata Yadav
    Jul, 2014 1

    sp_rename [ @objname = ] 'object_name' , [ @newname = ] 'new_name' [ , [ @objtype = ] 'object_type' ] 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.For Renaming database:ALTER DATABASE "CurrentDBName" MODIFY NAME = "NewDBName"

    • 1
  • Pankaj Bajaj
    Apr, 2014 27

    Hi Rakesh, Yes below commands are correct for renaming any object.To rename a Database you can use one more commandALTER DATABASE "CurrentDBName" MODIFY NAME = "NewDBName"

    • 1
  • Rakesh Singh
    Apr, 2014 24

    To rename db sp_renamedb ‘oldname' , ‘newname' To rename Table SP_RENAME ‘oldTableName', ‘NewTableName' To rename Column sp_RENAME ‘Table_First.Name', ‘NameChange' , ‘COLUMN'

    • 1
  • Mukesh Kumar
    Sep, 2017 5

    Alter

    • 0
  • Khan Abrar Ahmed
    May, 2014 8

    EXEC sys.sp_rename @objname = N'', -- nvarchar(1035)@newname = NULL, -- sysname@objtype = '' -- varchar(13)

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS