![]() |
Database »
Database »
Databases
Intermediate
SQL Server backup utilityBy Shabdar GhataRestore/backup selected objects in SQL Server. |
VB.NET 2.0, WinXP, Visual Studio, SQL 2000, SQL 2005, DBA, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
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.
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.
'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
objBCP.DataFilePath = "c:\temp\EmployeeData.dat"
db.Tables.Item("Employee").ExportData(objBCP)
'Generate script with drop statement
Dim SQL as String = _
db.GetObjectByName("Employee").Script(SQLDMO_SCRIPT_TYPE.SQLDMOScript_Drops) _
+ db.GetObjectByName("Employee").Script()
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.
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 3 Jun 2006 Editor: Smitha Vijayan |
Copyright 2006 by Shabdar Ghata Everything else Copyright © CodeProject, 1999-2009 Web20 | Advertise on the Code Project |