Aracılığıyla paylaş


sp_renamedb (Transact-SQL)

Veritabanının adını değiştirir.

Important noteImportant Note:

This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Bunun yerine, ALTER DATABASE MODIFY ADı kullanın.Daha fazla bilgi için bkz:ALTER DATABASE Transact-SQL).

Topic link iconTransact-SQL sözdizimi kuralları

sp_renamedb [ @dbname = ] 'old_name' , [ @newname = ] 'new_name'

Bağımsız değişkenler

  • [ @dbname=] 'old_name'
    Is the current name of the database.old_name is sysname, with no default.

  • [ @newname=] 'new_name'
    Is the new name of the database.new_name must follow the rules for identifiers.new_name is sysname, with no default.

Dönüş Kodu Değerleri

0 (başarılı) veya sıfır olmayan bir sayı (hata)

İzinler

Üyelik gerektirir sysadmin or dbcreator sunucu rollerini sabit.

Örnekler

Aşağıdaki örnek oluşturur Accounting Veritabanı ve sonra da veritabanının adını değiştirir Financial. The sys.databases catalog view is then queried to verify the new name of the database.

USE master;
GO
CREATE DATABASE Accounting;
GO
EXEC sp_renamedb N'Accounting', N'Financial';
GO
SELECT name, database_id, modified_date
FROM sys.databases
WHERE name = N'Financial';
GO