I have a scheduled task to runs a backup script each night using a program called SQL_Talk for Windows version 9.0.1. I am using this program to unload a SQLBase database each night for backup purposes. I have a separate script for each night of the week. Below is the Monday script:
set server server1;
connect testdb 1 sysadm/XXXXXX;
update statistics on database;
check database;
commit;
SET BULK ON;
unload database z:backupsVIS_Monday.UNL;
disconnect all;
EXIT;
Instead of unloading to a file named
VIS_Monday.UNL is it possible to change the script to embed the date of the unload in the filename? For example
VIS_Feb232009 ?
This would make for fewer scripts and I would not have to manually embed the dates in the file names.
If not, is there another scripting program that will allow this to be done?
Thanks!
-Flame
Software/Hardware used:
ASKED:
February 24, 2009 4:47 PM
UPDATED:
March 2, 2009 6:13 PM
Carlosdl,
I made a few changes listed below, but this is EXACTLY what I needed. The changes is made removed the space that was appearing after the filename, but before the “.txt” extension as well as a space that appeared between the filename and the “;”
Thank you!
-Flame
Modified bat file:
Resulting Script:
Perfect!
Wow, Silly mistake (which the system infomed me of…) You can’t have a “/” in a file name (doh!)
Fixed code below:
Batch file:
del Autoname_Unload.sql
set date=%date:~0,3%_%date:~4,2%_%date:~7,2%_%date:~10,4%.UNL;
echo set server server1; >> Autoname_Unload.sql
echo connect testdb 1 sysadm/XXXXXX; >> Autoname_Unload.sql
echo update statistics on database; >> Autoname_Unload.sql
echo check database; >> Autoname_Unload.sql
echo commit; >> Autoname_Unload.sql
echo SET BULK ON; >> Autoname_Unload.sql
echo unload database z:backupsVIS_%date% >> Autoname_Unload.sql
echo disconnect all; >> Autoname_Unload.sql
echo EXIT; >> Autoname_Unload.sql
Resulting Script:
set server server1;
connect testdb 1 sysadm/XXXXXX;
update statistics on database;
check database;
commit;
SET BULK ON;
unload database z:backupsVIS_Mon_03_02_2009.UNL;
disconnect all;
EXIT;
That’s better!
Thanks again Carlosdl!
Interesting note here…
The files I copied had the “” symbol in the correct places in the paths of the batch files… but they did not seem to paste into the discussion section… Is there a way to edit the comments to reflect this?
Apparently you can’t even type the symbol that is a mirror image to “/” in the discuss section. Interesting…
Yes Flame, you cannot use the mirror of ‘/’ here (I guess it is taken as some type of escape character)…
I noticed you change ‘>’ for ‘>>’ in this line:
echo set server server1; >> script.txt
Have you tried running this script more than once ? I think it will cause the new script to be appended at the end of the previously generated, so the file will grow endlessly.
Thats why the first line of the script is :
del Autoname_Unload.sql
I though the single “>” was a typo… (Needed more coffe this morning I guess…)
I’m planning on running a test tonight, then going live after that.
Thank you again!
Flame