如何rename sqlserver database
Problem
Sometimes there is a need to change the name of your database whether this is because the original name was based on some other project that is no longer relevant to the data stored in the database or maybe it was because you restored a database and at the time just gave it a temporary name, but long term it ended up being a database that needed to remain on your system.
Regardless of the reason there may come a time when you want to or need to rename a database. In this tip we look at a couple different options.
Solution
There are a few ways of doing this.
Option 1 - Rename SQL Server Database using T-SQL
This command works for SQL Server 2005, 2008, 2008R2 and 2012:
If you are using SQL Server 2000 you can use this T-SQL command to make the database name change. This still works for SQL 2005, 2008, 2008R2 and 2012, but Microsoft says it will be phased out at some time.
Option 2 - Rename SQL Database using SSMS
If you are using SQL Server Management Studio, right click on the database name and select the option "Rename". This did not exist in SQL Server 2000, but if you use Management Studio to manage SQL Server 2000 you can also take advantage of this option.

Option 3 - Rename SQL database using detach and attach
Use the detach and attach feature of SQL Server to detach the database first and when you reattach the database you give the database a different name. This can be done by using the SSMS or you can do this by using the following commands:
Here we are detaching database "Test"

Here we are reattaching database "Test", but before we finish we change the name of the database to "Test2".

One thing to note is by changing the name of the database using one of these techniques you are only renaming the database. The physical files still have the same names, so if you want to also change the name of the files the simplest approach is to use Option 3. Before you reattach the files you need to first change the name of the physical files and then when you do the reattach you can specify the renamed files.
如何rename sqlserver database的更多相关文章
- get your sqlserver database back by using EMC NW NMM
Dear all Yes ~ We can backup our sqlserver by EMC NW NMM. That is true and NW is a very very powerfu ...
- How to select a OptionSet on ms sqlserver database for Microsoft Dynamics CRM
OptionSet: Select * from StringMap Global OptionSet: select os.Name, l.Label from AttributePicklist ...
- P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1
P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1 May ...
- SQLSERVER性能计数器的简单剖析
SQLSERVER性能计数器的简单剖析 今晚看了这篇文章:SQL Server 2012新performance counter:非常实用的Batch Resp Statistics 文章里介绍到SQ ...
- Inno Setup connection to the database and create
原文 Inno Setup connection to the database and create Description: the first half of this program in I ...
- sqlserver 一键备份,异机还原脚本
REM +---------------------------------------------------------------------------------+ REM |desc AU ...
- Unity Ioc 类型初始值设定项引发异常,The type name or alias SqlServer could not be resolved. Please check your configuration file and verify this type name.
先看一下unity的配置信息 <unity> <typeAliases> <typeAlias alias="IDatabase" type=&quo ...
- 开发 ASP.NET vNext 续篇:云优化的概念、Entity Framework 7.0、简单吞吐量压力测试
继续上一篇<开发 ASP.NET vNext 初步总结(使用Visual Studio 2014 CTP1)>之后, 关于云优化和版本控制: 我本想做一下MAC和LINUX的self-ho ...
- AlwaysOn 部分笔记及文档连接
本文主要含有一些AlwaysOn 配置方法及连接. 本想展开详细写一下 无奈隔壁在年会排练节目,那歌唱得我只想赶紧回家!!!!!!!!!!!!!!! http://www.cnblogs.com/d ...
随机推荐
- 调整win7 Windows7下时间同步的频率时 钟同步间隔
今天发现时间不对,同步时间后看到Windows系统默认是一周才同步一次时间,频率太低了.查找了一下资料,找到了两种调整Win7时间同步频率的方法. 方法一:注册表法 这种方法是通过修改注册表中的键值来 ...
- PostgreSQL表空间、模式、表、用户/角色之间的关系
PostgreSQL表空间.模式.表.用户/角色之间的关系是本文我们主要要介绍的内容,表空间,数据库,模式,表,用户,角色之间的关系到底是怎样的呢?接下来我们就开始介绍这一过程. 实验出角色与用户的关 ...
- oracle vm virtualbox 如何让虚拟机可以上网
刚安装了虚拟机,系统linux2.6. 可是想安装一些软件,发现没法联网.郁闷~ 还要手动设置网络,可是也不是小白就可以干的事情,还要弄清楚原理才行. http://reverland.bitbuc ...
- DMSFrame 之简单用法(一)
1.DMSFrame是一个完整的ORM框架,框架相对来说也比成熟了.使用上有些地方还是比较方便的.DLL文件大约300K左右,但却可以支持各种方式的查询,完全的LINQ化的方式书写代码,更有利于维护. ...
- oracle 11g 如何创建、修改、删除list-list组合分区
Oracle11g在分区方面做了很大的提高,不但新增了4种复合分区类型,还增加了虚拟列分区.系统分区.INTERVAL分区等功能. 9i开始,Oracle就包括了2种复合分区,RANGE-HASH和R ...
- ORA-12170:TNS:连接超时
本文转自 http://www.cnblogs.com/kerrycode/archive/2012/12/14/2818421.html 1:首先检查网络是否能ping通 2:检查TNS配置(TNS ...
- 未在本地计算机上注册 Microsoft.Jet.OLEDB.4.0 提供程序
在C#的web程序中读取服务器端的Excel文件时所报的异常 问题描述:在Visual Studio中运行.调试均没有问题,但是部署到Windows Server 2008 64位操作系统的IIS7 ...
- `cocos2dx非完整` 游戏架构缩影 添加启动流程
这期的话题可能不是很好, 我没有想到很好的词句去更好的表达. 我一直都是很固执的认为, 同一类型的游戏,在开发做的前期工作上面其实都是可以复用的,也就是大同小异的.从游戏启动,启动日志,启动检查,检查 ...
- 简单学ES6 - class
前言 随着ES6标准的定稿,众多的特性也趋于稳定,各大浏览器也在逐步实现这些特性,那么对ES6有更多的了解就无可厚非了. 准备 在学习ES6之前,我们需要有一个环境来测试ES6代码.在这里我推荐使用n ...
- [Python] Basic operations in Pycharm
From: http://learnpythonthehardway.org/book Comment with line comment: Ctrl + slash Run: Shift + F10 ...