How To Get Database Backup using cursor and also only write down this code
Backup Database "database name" To Disk = "pathname"
SQL
DECLARE@nameASVARCHAR(50)
DECLARE@FileNameASVARCHAR(50)
DECLARE@filedateASVARCHAR(50)
SELECT@filedate=CONVERT(VARCHAR(20),GETDATE(),112)
DECLARE Db_cursor CURSORFORSELECT* NAME FROM MASTER.dbo.sysdatabases
WHERE NAME NOTIN ('master','model','msdb','tempdb')
OPEN Db_cursor
FETCH NEXT FROM Db_cursor INTO@name
WHILE @@FETCH_STATUS=0BEGINSET@FileName='E:\dhaval\'+@name+'_'+@filedate+'.Bak'
BACKUP DATABASE @nameTO DISK =@FileNameEND
And if you want to Restore it then write down this code
Set Single Restore Database "Database Name" From Disk = "Path name" Set Multiple
Set single and means single user database restore .then first of set single and database has restored then make multiple User.
0 comments
Comments
Join the conversation! Your thoughts help the community grow.
Join to leave a comment
Members earn 10 SHARP for a comment, 10 SHARP for a reaction, and 250 SHARP for every blog they publish.
Join the conversation! Your thoughts help the community grow.