How to Rename Database in SQL Server - SQL Server / T-SQL Tutorial Part 26
How to Rename Database in SQL Server - SQL Server / T-SQL Tutorial
Link to post for scripts used in the video.
http://www.techbrothersit.com/2016/02/how-to-rename-database-in-sql-server.html
Scenario:
We often face the situation where we need to rename the database. Think about situation, you are working as SQL Server developer for Financial firm and they have the database name TechBrothersIT and they would like to rename to Techbrothers. You need to provide the scripts that can be run in QA, UAT and Production environment.
Solution:
Renaming by GUI:
Renaming database is very easy, you can simply Right Click on Database and then choose Rename.
You will see that the name of database will prompt you for change. Go ahead and change it and hit Enter.
How to Rename Database by using TSQL:
You can use TSQL To rename database in SQL Server.
1) By using Sp_Rename System Stored Procedure
We can use sp_rename system Stored Procedure to rename database in SQL server. Let's say we would like to rename TechBrtohersIT to TechBrother. We can use below script.
sp_renamedb 'OldDatabaseName','NewDatabaseName'
EXEC sp_renamedb 'TechBrothersIT','TechBrothers'
2) Use Alter Database with Modify
We can use below script to rename. In this example, I am renaming TechBrothersIT To TechBrothers.
USE master;
GO
ALTER DATABASE TechBrothersIT
Modify Name = TechBrothers ;
GO
Common Error:
Let's say that the database is in use by different applications. you might get below error.
Msg 5030, Level 16, State 2, Line 4
The database could not be exclusively locked to perform the operation.
In this case, you can kill all connections before you run rename script. Below script can be used to kill all connections on a database.Make sure with your team and other teams before you kill all connections on database for renaming.
Check out our website for Different SQL Server, MSBI tutorials and interview questions
such as SQL Server Reporting Services(SSRS) Tutorial
SQL Server Integration Services(SSIS) Tutorial
SQL Server DBA Tutorial
SQL Server / TSQL Tutorial ( Beginner to Advance)
http://www.techbrothersit.com/
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «How to Rename Database in SQL Server - SQL Server / T-SQL Tutorial Part 26», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.