salve
vorrei duplicare un database
ho provato as crivere
DECLARE @DB_Name_source nvarchar(50);
DECLARE @DB_Name_destination nvarchar(50);
SET @DB_Name_source = 'aaa'
SET @DB_Name_destination = 'bbb'
DBCC CLONEDATABASE (@DB_Name_source, @DB_Name_destination)
--WITH VERIFY_CLONEDB, BACKUP_CLONEDB;
GO
ottengo il risultato ma SOLA LETTURA
se invece
-- 1) On Source DB Server - Create backup to local file
DECLARE @SourceFile AS VARCHAR(500);
DECLARE @DestinationFile AS VARCHAR(500);
DECLARE @SourceDB nvarchar(50);
DECLARE @DestinationDB nvarchar(50);
DECLARE @Cmd AS VARCHAR(500);
SET @SourceFile = 'c:\temp\Test\abc.bak'
SET @SourceDB = 'abc'
SET @DestinationFile = 'c:\temp\Test\cba.bak'
SET @DestinationDB = 'cba'
BACKUP DATABASE @sourceDB TO DISK = @SourceFile
-- 2) Copy the Source File to Destination Server.
--If both servers are on the same machine, you might want to create a copy of that file:
/* build copy command */
SET @Cmd = 'COPY "' + @SourceFile + '" "' + @DestinationFile + '"';
/* execute copy command */
EXEC master.dbo.xp_cmdshell @Cmd;
ottengo errore
BACKUP DATABASE ha elaborato 2220 pagine in 0.255 secondi (67.987 MB/sec).
Messaggio 15281, livello 16, stato 1, procedura xp_cmdshell, riga 1 [riga iniziale del batch 0]
SQL Server ha bloccato l'accesso all'oggetto procedura 'sys.xp_cmdshell' del componente 'xp_cmdshell' perché tale componente è disabilitato in base alle configurazione di sicurezza del server.
L'utilizzo di 'xp_cmdshell' può essere abilitato dall'amministratore di sistema tramite sp_configure.
Per ulteriori informazioni sull'abilitazione di 'xp_cmdshell', cercare 'xp_cmdshell' nella documentazione online di SQL Server.