Skip to main content
Email Password   helpLost your password?

Introduction

Whenever we want to backup or move SQL Server databases, most of us prefer to use a regular backup utility which is available through the Enterprise Manager in SQL Server 2000 or the Management Studio available in SQL Server 2005. The limitation of using the Enterprise Manager or the Management Studio is we have to use either complete or differential backups. This is a very tedious task when we want to backup only a small portion of a large database. For example, in my database, I would like to take the backup of only 15 tables out of 100 tables. I want to backup only a few records from these selected tables. For that reason, I was looking for a small utility which allows me ht facility. After searching through hundreds of utility programs, I decided to write my own.

Features

Using the program

To backup the database:

To restore the backup:

Using other features

Using the code

I am not writing the description of the code in much detail. Most of the code is self explanatory and commented. Just a few quick notes. I have used the SQL-DMO library for all database related tasks. For the SQL-DMO library, either SQL Express or SQL Server 2000 client tools must be installed on your computer.

Objects from the SQL-DMO library

'Server object from SQL-DMO library

Dim oServer As New SQLServer2
'Database object from SQL-DMO library

Dim db As SQLDMO.Database2
'BCP Utility from SQL-DMO Library

Dim objBCP As New SQLDMO.BulkCopy2

Function for exporting data to a file from SQL Server

objBCP.DataFilePath = "c:\temp\EmployeeData.dat"
db.Tables.Item("Employee").ExportData(objBCP)

Generating SQL script for a SQL Server object

'Generate script with drop statement

Dim SQL as String = _
  db.GetObjectByName("Employee").Script(SQLDMO_SCRIPT_TYPE.SQLDMOScript_Drops) _
  + db.GetObjectByName("Employee").Script()

Limitations

Enhancements

Acknowledgments

I have used SharpZipLib (ICSharpCode.SharpZipLib.dll), a free open source Zip utility library available from www.icsharpcode.net, for zipping the backup directory. This file is included in the Bin\Release folder.

Requirements

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralPerfect! Pin
reachen
20:21 27 Sep '09  
GeneralThanks for sharing this! Pin
reachen
7:23 18 Aug '09  
Generali am using EZManage SQL Pro to backup my sql servers Pin
itayl
4:09 27 May '09  
GeneralThanks a bunch! Pin
jm0077
10:28 27 Feb '09  
QuestionError when i Restore data Pin
Member 1471517
9:07 13 Feb '09  
GeneralGreat article, take a look at that tool also. Pin
roby54
12:03 8 Nov '08  
JokeCongratulations Pin
rolandocamachorojas
12:57 1 Aug '08  
GeneralError while taking back up from Backup Utility Pin
ershad
5:24 24 Jun '08  
GeneralBrilliant! Pin
toddwprice
11:40 3 Jun '08  
GeneralDoesn't work with Vista... Pin
Yogiman
8:01 14 Mar '08  
NewsNew version of this utility is available Pin
Shabdar Ghata
12:10 22 Nov '07  
GeneralRestore is empty Pin
ocram1
11:24 11 Oct '07  
AnswerRe: Restore is empty Pin
Shabdar Ghata
12:22 11 Oct '07  
GeneralRe: Restore is empty Pin
ocram1
12:48 12 Oct '07  
GeneralWithout sqldmo library Pin
zawmn83
22:12 19 Sep '07  
Questionproblem in inserting row Pin
gaurav kumar jaiswal
23:28 26 Aug '07  
AnswerRe: problem in inserting row Pin
majid_vb
12:34 28 Oct '07  
Generallogin form Pin
zaqxsws3210
18:06 20 Aug '07  
Generalek!!plzz Pin
m.rizal
17:48 20 Aug '07  
QuestionUnKnownError Pin
anahita_m
1:25 27 May '07  
AnswerRe: UnKnownError Pin
ershad
9:18 21 Jun '08  
Generalcannot connect ErrorProviderExtended1 Pin
ryan1214
4:53 3 Apr '07  
GeneralForeign_keys problem Pin
eugenia54
13:50 29 Dec '06  
Generaloutofmemoryexception Pin
eugenia54
11:31 20 Dec '06  
Generalexception of type system.outofmemoryexception was thrown Pin
zerdust_reso
4:05 14 Dec '06  


Last Updated 3 Jun 2006 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009