Collections:
"sp_rename ... 'COLUMN'" - Renaming an Existing Column in SQL Server
How to rename an existing column with the "sp_rename" stored procedure in SQL Server?
✍: FYIcenter.com
If you have an existing column in a table and you want to change the column name, you can use the "sp_rename ... 'COLUMN'" stored procedure. "sp_rename" allows you to change names of COLUMN, DATABASE, INDEX, USERDATATYPE, and OBJECT. The tutorial example below shows you how to rename a column:
USE master GO sp_rename 'tip.subject', 'title', 'COLUMN' GO Msg 15248, Level 11, State 1, Procedure sp_rename, Line 213 Either the parameter @objname is ambiguous or the claimed @objtype (COLUMN) is wrong. USE FyiCenterData GO sp_rename 'tip.subject', 'title', 'COLUMN' GO Caution: Changing any part of an object name could break scripts and stored procedures. SELECT id, title, description, author FROM tip GO id title description author 1 Learn SQL Visit dev.fyicenter.com NULL
You are getting the first error because 'FyiCenterData' is not the current database.
⇒ Renaming an Existing Column with Management Studio in SQL Server
⇐ "ALTER TABLE ... DROP COLUMN" - Deleting Existing Columns in SQL Server
2016-11-17, 3454🔥, 0💬
Popular Posts:
How To Convert Numeric Values to Integers in SQL Server Transact-SQL? Sometimes you need to round a ...
How To Update Multiple Rows with One UPDATE Statement in SQL Server? If the WHERE clause in an UPDAT...
How REAL and FLOAT Literal Values Are Rounded in SQL Server Transact-SQL? By definition, FLOAT(n) sh...
What Is Program Global Area (PGA) in Oracle? A Program Global Area (PGA) is a memory buffer that is ...
What Is the Difference Between GETDATE() and GETUTCDATE() in SQL Server Transact-SQL? The difference...