473,473 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

All database backup in a single query

92 Recognized Expert New Member
Use this query to get a whole backup of your database

Expand|Select|Wrap|Line Numbers
  1. USE MASTER
  2. DECLARE @dbName varchar(100) 
  3. DECLARE @dbPath varchar(100) 
  4. DECLARE dbName_Cur CURSOR FOR
  5. SELECT    Name FROM SYSDATABASES WHERE SID<>0x01
  6. OPEN dbName_Cur
  7. FETCH NEXT FROM dbName_Cur
  8. INTO @dbName
  9. WHILE @@FETCH_STATUS=0
  10.     BEGIN
  11.     -- HERE SET YOU BACKUP FOLDER NAME
  12.     SET @DBPATH='C:\RND\'+@dbName+CONVERT(VARCHAR,GETDATE(),112) +'.bkp'    
  13.     BACKUP DATABASE @DBNAME TO  DISK = @dbpath WITH  INIT, NOUNLOAD,NAME = N'CHKBKP',NOSKIP,STATS = 10,NOFORMAT
  14.     FETCH NEXT FROM dbName_Cur
  15.     INTO @dbName
  16.     end;
  17. CLOSE dbName_Cur
  18. DEALLOCATE dbName_Cur
  19. PRINT 'Completed..........'
  20. GO
May 2 '09 #1
0 4428

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: newbiegca_sqlsever2000 | last post by:
Question 1 3 GHZ CPU (Intel pentium 4) single cpu + 2 GB Memory + SCSI HDD Database size 10 GB - How long will full database backup take if the backup is writing a file to the hard disk...
3
by: rcamarda | last post by:
I do weekly full backups of my SQL databases via a scheduled T-SQL job. I noticed that I have some static databases that dont normally change, so I dont want to back it up if it has not changed,...
8
by: Gail Zacharias | last post by:
I am investigating the possibility of using pgsql as the database in an application. I have some unusual requirements that I'd like to ask you all about. I apologize in advance if my terminology is...
5
by: Frank van Vugt | last post by:
Hi, I noticed that when using the single commandline: drop database <name>; create database <name>; this sometimes fails due to a pg_autovacuum process running on the background. When...
5
by: Deano | last post by:
I'm experiencing bloat problems when I restore my backup files. Users can take a look at the reports of any previous backup without having to ensure they have a backup of their current data - this...
18
by: Wim | last post by:
Hi, I would like to make and put a query in my database by VB.NET code. Is this possible? Thanks for your help, wim
5
by: HSP | last post by:
hi. i need to restore an old database. The db was backed up using a DLT drive, using 2 volumes. The content for the tapes was copied to file onto Solaris machine using rsh and dd (for backup...
2
by: barrathi | last post by:
hai all, i have 10 database in one server. i need to take a backup daily iam using this type of query ex: mysqldump -a -u root -p dbname > dbname.sql(for each db) but i need
1
by: kitemad69 | last post by:
How i can i deploy and attach a database from a C# project. I created the database in sql manager now i want to deploy it using a C# project is this possible
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.