SQL server 2005 Express Backup

  • Hello all,

    I have an mdf file in the vb.net project I am involved in. I wanted to write an sp that will create a back up of the db in a selected location.

    the sp uses following statements:-

    USE master

    GO

    EXEC sp_addumpdevice 'disk', 'AdvWorksData',

    'Z:\SQLServerBackups\AdvWorksData.bak';

    GO

    BACKUP DATABASE AdventureWorks TO AdvWorksData;

    GO

    when I execute it from SSMO after attaching the file, it works.

    But this does not work when I call it from the application.

    What can I do?

  • You need to make one Stored Procedure in your database and then call the stored procedure from your application code.

    Hope this will help you.

  • You could do this with a single SQL statement, rather than having to add a dump device:

    BACKUP DATABASE AdventureWorks TO DISK='Z:\SQLServerBackups\AdvWorksData.bak'

    Does that work?

  • I tried your suggestion. I am getting a error message that no entry could be found in the sysobjects with the name of the database. The mdf file that I am using is not attached to the SQL Server Express. Is that the reason? If so, is there any walk around?

  • If the MDF isn't attached as a database you could back it up by just copying the file somewhere else--it won't be locked if SQL server isn't using it.

  • I am currently doing that only. Just wanted to check with experts if there is a possibility to back up using the standard methods...... Guess I have to resign with this method.....

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply