1

Before my migration from MSDE (SQL Server 2000) to SQL Server 2008 R2 Express, I used the following sentence to take a backup of my database :

C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Binn>sqlmaint.exe 
    -S \"(local)\\SQLEXPRESS"\ 
    -D \"DB Name"\ 
    -BkUpDB \@"C:\Documents and Settings\emmug\Application Data\CalibrationSystem\Backup"\ 
    -BkUpMedia DISK

But now, I get this error :

Microsoft (R) SQLMaint Utility (Unicode), Version 10.0.1600.22
Copyright (c) Microsoft Corporation.
The SQLDMO 'Application' object failed to initialize (specific error: One of the library files needed to run this application cannot be found.)

So I saw that SQLDMO was not supported in SQL Server 2008 R2 but I could use Microsoft SQL Server 2005 Backward Compatibility Components. Unfortunately, that doesn't work.

Microsoft now uses SQL Server Management Objects (SMO) but there don't give any code sample to help me.

So is there somebody know a solution for my issue ?

Thanks

Emmanuel

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Emmanuel
  • 11
  • 2

1 Answers1

0

You can use SQLCMD.exe, e.g

SQLCMD.exe -S "(local)\SQLEXPRESS" -Q"BACKUP DATABASE dbName TO DISK = 'C:\Documents and Settings\emmug\Application Data\CalibrationSystem\Backup\dbname.bak'"

RichardTheKiwi
  • 105,798
  • 26
  • 196
  • 262
  • Thanks for the answer. But when I execute this command, I have this error message : C:\Program Files\Microsoft SQL Server\100\Tools\Binn>SQLCMD.exe -S "(local)\SQLEXPRESS" -Q"BACKUP DATABASE AIX TO DISK = 'C:\Documents and Settings\...\Backup\dbname.bak'" Msg 3201, Level 16, State 1, Server WKSQC02615\SQLEXPRESS, Line 1 Cannot open backup device 'C:\Documents and Settings\...\Backup\dbname.bak'. Operating system error 5(Access is denied.). Msg 3013, Level 16, State 1, Server WKSQC02615\SQLEXPRESS, Line 1 BACKUP DATABASE is terminating abnormally. What I do wrong ? – Emmanuel Dec 07 '12 at 15:14
  • `Operating system error 5(Access is denied.).` The folder is not writeable to the Windows Account that runs the SQL Server (SQLEXPRESS) service. Pick a friendly location, e.g. `C:\temp\sqlbackups` and give "Everyone" *Modify* permissions, the backup to the location – RichardTheKiwi Dec 07 '12 at 15:28