Thursday, April 3, 2014
Full backup databases starting with i8
20140403 JJM (c) i8 solutions
*/
DECLARE @eSQL NVARCHAR(MAX)
DECLARE C cursor for
select 'BACKUP DATABASE ['+name+'] TO DISK = N''D:\i8\BU\'+ name +'.bak'' WITH NOFORMAT,
INIT,
NAME = N'''+ name + '-Full Database Backup'',
SKIP,
NOREWIND,
NOUNLOAD,
STATS = 10' from master.sys.databases
where name like 'i8%'
OPEN C
FETCH NEXT FROM C INTO @eSQL
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC (@eSQL);
FETCH NEXT FROM C INTO @eSQL
END
CLOSE C
DEALLOCATE C
Till Next Time
Wednesday, August 19, 2009
Friday, January 23, 2009
MSSQL Restore DB using TSQL
Step 1: Retrive the Logical file name of the database from backup. RESTORE FILELISTONLY
FROM DISK = ‘D:BackUpYourBaackUpFile.bak’
GO
Step 2: Use the values in the LogicalName Column in following Step. —-Make Database to single user Mode
ALTER DATABASE YourDB
SET SINGLE_USER WITH
ROLLBACK IMMEDIATE
—-Restore Database
RESTORE DATABASE YourDB
FROM DISK = ‘D:BackUpYourBaackUpFile.bak’
WITH MOVE ‘YourMDFLogicalName’ TO ‘D:DataYourMDFFile.mdf’,
MOVE ‘YourLDFLogicalName’ TO ‘D:DataYourLDFFile.mdf’
/*If there is no error in statement before database will be in multiuser
mode.
If error occurs please execute following command it will convert
database in multi user.*/
ALTER DATABASE YourDB SET MULTI_USER
GO