如何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 ...
随机推荐
- Maximum Entropy Markov Models for Information Extraction and Segmentation
1.The use of state-observation transition functions rather than the separate transition and observat ...
- VPN各种常见状态码及修复方法
1.633错误 :由于Windows系统本身的问题,在PPTP协议连接多次并断开之后,后导致一直出现633错误.参见微软的官方解决方案:http://support.microsoft.com/kb/ ...
- java---Swing界面开发总结
一.java的图形界面 1.awt java.awt jdk1.4之前推出的图形界面,用c/c++编写,跨平台性不好 2.swing javax.swing jdk1.4时推出的图形界面,跨平 ...
- SNF开发平台WinForm之七-单据打印和使用说明-SNF快速开发平台3.3-Spring.Net.Framework
8.1运行效果: 8.2开发实现: 1. 先要创建.grf报表模版,指定数据列.存储位置:Reports\Template文件夹下 2. 之后在程序当中查出数据,之后把数据和打印模版 传入方法进行 ...
- Unity 资源管理与更新
当你在 工程目录下的 Asset 文件夹中放置一个文件时(电脑上的文件夹,不是 Unity 界面中的文件夹),Unity会自动检测到一个新的文件被添加(Unity会不停地检查Assets文件夹中的内容 ...
- 显示SQL Server分配的全部内存
1.在sqlserver 中建立查询 2.执行 DBCC MEMORYSTATUS 在Windows Server 2000/2003任务管理器中,“内存使用”这个字段是显示工作区分配的内存.一个进程 ...
- 清除linux缓存命令
命令 #sync #echo 3 > /proc/sys/vm/drop_caches 查看内存情况: # more /proc/meminfo Kernels 2.6.16 and newer ...
- Rainyday.js – 傻眼了!竟然有如此逼真的雨滴效果
Rainyday.js 是一个轻量的 JavaScript 库,利用 HTML5 Canvas 实现雨滴下落在玻璃表面的动画效果.Rainyday.js 尽可能的模拟现实的雨滴效果,几乎可以以假乱真了 ...
- [python]逆水行舟不进则退(1)
工作后迎来的第一个长假期,打算在家休息一下,看看书之类的.但是不写点东西,不做点东西,感觉有些浪费时间.同时也想通过做点东西检验下自己这段时间的收获.其实在我开始写这篇文章的时候心里还是很没底的-交代 ...
- Windows及Linux平台下的计时函数总结
本文对Windows及Linux平台下常用的计时函数进行总结,包括精度为秒.毫秒.微秒三种精度的各种函数.比如Window平台下特有的Windows API函数GetTickCount().timeG ...