Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Backing up sql server db with a batch file

Author  Topic 

binodbdrchand
Starting Member

1 Post

Posted - 2009-06-18 : 05:45:08
Here is the batch file :

@ECHO OFF
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do set today=%%e-%%f-%%g
set dirPath=C:\Backups\%today%
mkdir %dirPath%
ECHO Directory %dirPath% created.
set filePath=%dirPath%\test before day end.bak
set sql=EXEC BackupDB %filePath%
osql -U username -P passwd -d Test -Q "%sql%"
ECHO DB backed up.

Here is the stored procedure :
CREATE PROCEDURE BackupDB @path VARCHAR(100)
AS
BACKUP DATABASE Test
TO DISK = @path
GO

The given error is :
Msg 170, Level 15, State 1, Server SERVER, Line 1
Line 1: Incorrect syntax near '\'.

Someone please help.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-06-18 : 05:52:14
fast shot: test before day end.bak should be test_before_day_end.bak


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -