Code:
BACKUP DATABASE abc_SuperAdmin
TO DISK = 'c:\abc_SuperAdmin.bak'
RESTORE FILELISTONLY
FROM DISK = 'c:\abc_SuperAdmin.bak'
RESTORE DATABASE TestDB
FROM DISK = 'c:\abc_SuperAdmin.bak'
WITH MOVE 'abc_SuperAdmin_data' TO 'c:\testdb.mdf',
MOVE 'abc_SuperAdmin_log' TO 'c:\testdb.ldf'
//////////////////////////////
BACKUP DATABASE abc_SuperAdmin
TO DISK = 'c:\abc_SuperAdmin.bak'
RESTORE FILELISTONLY
FROM DISK = 'c:\abc_SuperAdmin.bak'
RESTORE DATABASE TestDB
FROM DISK = 'c:\abc_SuperAdmin.bak'
WITH MOVE 'abc_SuperAdmin_data' TO 'c:\testdb.mdf',
MOVE 'abc_SuperAdmin_log' TO 'c:\testdb.ldf'
//////////////////////////////
SP
CREATE PROCEDURE sp_AddDatabase
@DatabaseName varchar(255),
@BakFilePath varchar(255)
AS
Declare @DatabaseNameMdf VARCHAR(255)
Declare @DatabaseNameLdf VARCHAR(255)
SELECT @DatabaseNameMdf = 'C:\Program Files\Microsoft SQL Server\MSSQL$abcd2000\Data\
SELECT @DatabaseNameLdf = 'C:\Program Files\Microsoft SQL Server\MSSQL$abcd2000\Data\
RESTORE DATABASE @DatabaseName
FROM DISK = @BakFilePath
WITH MOVE 'abc_Events_Data' TO @DatabaseNameMdf,
MOVE 'abc_Events_log' TO @DatabaseNameLdf
GO
No comments:
Post a Comment