共用方式為


Restore.ReplaceDatabase 屬性

Gets or sets a Boolean value that specifies whether a restore operation creates a new image of the restored database.

命名空間:  Microsoft.SqlServer.Management.Smo
組件:  Microsoft.SqlServer.SmoExtended (在 Microsoft.SqlServer.SmoExtended.dll 中)

語法

'宣告
Public Property ReplaceDatabase As Boolean 
    Get 
    Set
'用途
Dim instance As Restore 
Dim value As Boolean 

value = instance.ReplaceDatabase

instance.ReplaceDatabase = value
public bool ReplaceDatabase { get; set; }
public:
property bool ReplaceDatabase {
    bool get ();
    void set (bool value);
}
member ReplaceDatabase : bool with get, set
function get ReplaceDatabase () : boolean 
function set ReplaceDatabase (value : boolean)

屬性值

型別:System.Boolean
A Boolean value that specifies whether a new image of the restored database will be created.If True, a new image of the database is created. The image is created regardless of the presence of an existing database with the same name.If False (default), a new image of the database is not created by the restore operation. The database that is targeted by the restore operation must exist on an instance of SQL Server.

範例

The following code example sets the restore operation to create a new image of the restored database.

VB

Dim rs As Restore
rs = New Restore
rs.ReplaceDatabase = true

PowerShell

$rs = new-object Microsoft.SqlServer.Management.Smo.Restore
$rs.ReplaceDatabast = $TRUE

請參閱

參考

Restore 類別

Microsoft.SqlServer.Management.Smo 命名空間

其他資源

RESTORE (Transact-SQL)

SQL Server 資料庫的備份與還原