TechNet
Products
IT Resources
Downloads
Training
Support
Products
Windows
Windows Server
System Center
Microsoft Edge
Office
Office 365
Exchange Server
SQL Server
SharePoint Products
Skype for Business
See all products »
Resources
Channel 9 Video
Evaluation Center
Learning Resources
Microsoft Tech Companion App
Microsoft Technical Communities
Microsoft Virtual Academy
Script Center
Server and Tools Blogs
TechNet Blogs
TechNet Flash Newsletter
TechNet Gallery
TechNet Library
TechNet Magazine
TechNet Wiki
Windows Sysinternals
Virtual Labs
Solutions
Networking
Cloud and Datacenter
Security
Virtualization
Updates
Service Packs
Security Bulletins
Windows Update
Trials
Windows Server 2016
System Center 2016
Windows 10 Enterprise
SQL Server 2016
See all trials »
Related Sites
Microsoft Download Center
Microsoft Evaluation Center
Drivers
Windows Sysinternals
TechNet Gallery
Training
Expert-led, virtual classes
Training Catalog
Class Locator
Microsoft Virtual Academy
Free Windows Server 2012 courses
Free Windows 8 courses
SQL Server training
Microsoft Official Courses On-Demand
Certifications
Certification overview
Special offers
MCSE Cloud Platform and Infrastructure
MCSE: Mobility
MCSE: Data Management and Analytics
MCSE Productivity
Other resources
Microsoft Events
Exam Replay
Born To Learn blog
Find technical communities in your area
Azure training
Official Practice Tests
Support options
For business
For developers
For IT professionals
For technical support
Support offerings
More support
Microsoft Premier Online
TechNet Forums
MSDN Forums
Security Bulletins & Advisories
Not an IT pro?
Microsoft Customer Support
Microsoft Community Forums
Sign in
Home
Library
Wiki
Learn
Gallery
Downloads
Support
Forums
Blogs
Resources For IT Professionals
United States (English)
Россия (Pусский)
中国(简体中文)
Brasil (Português)
Skip to locale bar
Post an article
Translate this page
Powered by
Microsoft® Translator
Wikis - Page Details
First published by
Mehmet GÜZEL
When:
30 Nov 2011 3:08 AM
Last revision by
Gokan Ozcifci
(eMicrosoft Partne)
When:
31 Jul 2013 10:28 AM
Revisions:
3
Comments:
1
Options
Subscribe to Article (RSS)
Share this
Can You Improve This Article?
Positively!
Click Sign In to add the tip, solution, correction or comment that will help other users.
Report inappropriate content using
these instructions
.
Wiki
>
TechNet Articles
>
Veritabanı Adını Değiştirme - Change Database Name (tr-TR)
Veritabanı Adını Değiştirme - Change Database Name (tr-TR)
Article
History
Veritabanı Adını Değiştirme - Change Database Name (tr-TR)
Bir çok yerde ismi değiştirilecek veritabanı önce
single_user
mode alınıp ardından isim değişikliği yapacak T-SQL kodlar paylaşılıyor. Evet, ismi değiştirilecek veritabanı adını
single_user
mode alıp değiştirebilirsiniz hatta SQL Server ile ilgili bir çok kaynakta Master veritabanını seçtirerek
single_user
moda alma şeklinde yapılmış.
Fakat sakın ola
master
veritabanı seçili iken ismini değiştireceğiniz veritabanını
single_user
moda almayın; aşağıdaki gibi hata mesajları alırsınız:
Hata Mesajı-1:
“Msg 5064, Level 16, State 1, Line 1
Changes to the state or options of database 'databasename' cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.”
Hata Mesajı-2:
"Msg 1205, Level 13, State 68, Line 1
Transaction (Process ID XXX) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed."
Bu durumda ilgili veritabanına tüm erişimleri kesmeden veritabanı ismini değiştirip
multi_user
moda alamazsınız. Önce
single_user
moda alıp veritabanını ismini değiştirecekseniz ilgili scriptinizi ismini değiştirmek istediğiniz veritabanını seçerek(USE) single_user mode alınız. Bu durumda single_user sizin mevcut bağlantınız olur. Bu tür sorunları ve sistem kesintisine mahal vermemek için aşağıdaki iki scripten dilediğinizi kullanıp uygulayabilirsiniz:
Script-1:
use [master]
go
-- set database to restricted_user mode
alter
database
[databasename]
set
restricted_user
with
rollback
immediate
-- rename database name
alter database
[databasename]
modify
name
=
[databasename_new]
--set database to multi-user mode
alter
database
[databasename]
set
multi_user
with
rollback
immediate
Script-2:
use
[databasename]
go
-- set database to restricted_user mode
alter
database
[databasename]
set
single_user
with
rollback
immediate
-- rename database name
alter database
[databasename]
modify name =
[databasename_new]
--set database to multi-user mode
alter
database
[databasename]
set
multi_user
with
rollback
immediate
Not:
İlgili veritabanını kullanmaya çalışan session'ları aşağıdaki kod ile sonlandırabilirsiniz:
declare @tsql varchar(max)=''
select distinct @tsql = @tsql + 'kill ' + cast(request_session_id as varchar(16)) +';
'
from sys.dm_tran_locks
where resource_database_id=db_id('databasename')
group by request_session_id
exec(@tsql)
DDL
,
SQL Server
,
SQL Server 2008
,
tr-TR
,
T-SQL
[Edit tags]
Leave a Comment
Please add 2 and 5 and type the answer here:
Post
Wiki - Revision Comment List(Revision Comment)
Sort by:
Published Date
|
Most Recent
|
Most Useful
Comments
Ed Price - MSFT
20 Dec 2011 3:23 PM
Ed Price - MSFT edited Original. Comment: Added Turkish code to title.
Edit
Page 1 of 1 (1 items)
Wikis - Comment List
Sort by:
Published Date
|
Most Recent
|
Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
Posted by
Ed Price - MSFT
on
20 Dec 2011 3:23 PM
Ed Price - MSFT edited Original. Comment: Added Turkish code to title.
Edit
Page 1 of 1 (1 items)