Answer the question
In order to leave comments, you need to log in
Table backup automatically in MSSQL Server?
Hello.
Set the task to automate the execution of another task.
There was a backup of the tables (before the subsequent change), as follows:
select * into dwh2.REF.INTERNAL_ORG_ASSOC_backup_20170411 from dwh2.REF.INTERNAL_ORG_ASSOC
Answer the question
In order to leave comments, you need to log in
If you do not deviate from this method, you need to somehow feed the SQL Server the table name generated automatically.EXECUTE
Is it possible?
Yes, you can do something like this in a bat file, then add it to the task.
@echo off
mode con cp select=1251
for /f %%x in ('wmic path win32_localtime get /format:list ^| findstr "="') do set %%x
ECHO select * into dwh2.REF.INTERNAL_ORG_ASSOC_backup_%Year%%Month%%Day% from dwh2.REF.INTERNAL_ORG_ASSOC>"BackUp.sql"
ECHO GO>>"BackUp.sql"
ECHO [%date% %time%] Start BackUp >> "BackUp.log"
sqlcmd -E -d dwh2 -i "BackUp.sql" >> "BackUp.log"
DEL /F "BackUp.sql"
mode con cp select=866
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question