Friday 24 January 2020

How to rename a database and table in SQL Server

Hi All,

Hope you all are doing good.

In this article, I will explain you about how to rename a database and table in SQL server.


Rename Database:

By using sp_renamedb stored procedure, we can rename our database in SQL server.
Syntax:EXEC SP_RENAMEDB 'old_database_name', 'new_database_name'
Example:EXEC SP_RENAMEDB 'Stores', 'ProductsStores'

Rename Database using Alter statement

Syntax:Alter database DatabaseName Modify Name = NewDatabaseName
Example:Alter database Stores Modify Name = ProductsStores

Rename Table:

By using sp_rename stored procedure, we can rename our table in SQL server.
Syntax:EXEC SP_RENAME 'old_table_name', 'new_table_name'
Example:EXEC SP_RENAME 'Products', 'CustomerProducts';

Thanks for reading my article.

No comments:

Post a Comment

Intoduction to Flutter

Hi All, I hope every one is doing good In this article, we will know about the introduction of Flutter.