I realize this is syntactically bad but I figure it somewhat explains what I’m trying to do. Essentially, I have a batch job that is going to run each morning on a small table and as a part of the spec I need to create a backup prior to each load that can be accessed by a report.
What I have so far is:
select *
into report_temp.MSK_Traffic_Backup_ + getdate()
from property.door_traffic
How can I make this function or should I consider doing this a better way?
Now, you might also want to add some logic to make the script immune to error if run more than once in a given day, e.g.
When you’re happy with the logic and want to execute the command, just swap the comments between
PRINTandEXEC.