sql server rename
Intro
有时候我们可能会需要重命名表名称或列名称,这里就是解决方案
sometimes we may wanna rename the table name or the column name, here's the solution.
Caution
Changing any part of an object name can break scripts and stored procedures. We recommend you do not use this statement > to rename stored procedures, triggers, user-defined functions, or views; instead, drop the object and re-create it with the new > name.
execute sql
rename a table name:
重命名表名
exec sp_rename 'schema.old_table_name', 'new_table_name'
-- To rename a column:
sp_rename 'table_name.old_column_name', 'new_column_name' , 'COLUMN';
-- To rename a table:
sp_rename 'old_table_name','new_table_name';
网友评论