backup of database tables using using

Posted by Abhi_patil under ASP.NET on 6/16/2009 | Views : 2461 | Status : [Member] | Replies : 1
I want to get back up of my some database tables in my disk folder..
how to get using c# +
plz suggest's urgent


Posted by: Vuyiswamb on: 6/17/2009 [Member] [MVP] [Administrator] NotApplicable

Good Morning Abhi_patil

That is Simple , Sometimes in order to solve a problem you need to break it into smaller problems. First you need to know how you create a Backup in SQl , and this is how its done

-- backup a database

create PROCEDURE [dbo].[sp_BackupDatabase]

@databasename varchar(32),
@path varchar(256),
@filename varchar(64)


set nocount on

declare @sql varchar(4000)

select @sql = 'BACKUP DATABASE ' + ltrim(rtrim( @databasename ))
select @sql = @sql + ' TO DISK = ''' + ltrim(rtrim(@path)) + ltrim(rtrim(@filename)) + ''' '
select @sql = @sql + ' WITH INIT'
--print @sql
execute ( @sql )

select 'Database successfully backed up!' [Result]

and this Accepts

@databasename varchar(32),

@path varchar(256),
@filename varchar(64)

The First Parameter is the Database you want to Backup and the Second parameter is the Path where you want you database backup to be stored and the last part is the name given to the backup.

and in C# you will call this sp as others.

Simple nee :)

Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response