Rename Database Using T-SQL in SQL Server 2008

In this article I describe how to change database name using SQL query.
  • 1846

Introduction

In this article I describe how to rename database using T-SQL statement. There are various approaches to change SQL Server database name. Sometimes condition arises when you need to rename your database like refreshing the development server with current data or while restoring database and at that time you just give a temporary name but after that you need to rename it on your system.

Syntax

ALTER DATABASE 'Old_Database_Name' MODIFY NAME= 'New_Database_Name'

Change database name using T-SQL statement

Step 1

Open SQL Server Management Studio and connect to database engine.

Step 2

Open New Query window.

Step 3

Type following code and execute it.

/* create databse */

create database EmployeeDetails

GO

/* change database name*/

alter database EmployeeDetails

modify name= EmployeePersonalDetails

Output:

rename database.jpg

Categories

More Articles

© 2013 dotNetheaven. All rights reserved.