Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8098055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:57:33+00:00 2026-06-05T21:57:33+00:00

I realize this is syntactically bad but I figure it somewhat explains what I’m

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:57:35+00:00Added an answer on June 5, 2026 at 9:57 pm
    DECLARE @d CHAR(10) = CONVERT(CHAR(8), GETDATE(), 112);
    
    DECLARE @sql NVARCHAR(MAX) = N'select  *
    into    report_temp.MSK_Traffic_Backup_' + @d + '
    from    property.door_traffic;';
    
    PRINT @sql;
    --EXEC sys.sp_executesql @sql;
    

    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.

    DECLARE @d CHAR(10) = CONVERT(CHAR(8), GETDATE(), 112);
    
    IF OBJECT_ID('report_temp.MSK_Traffic_Backup_' + @d) IS NULL
    BEGIN
      DECLARE @sql NVARCHAR(MAX) = N'select  *
      into    report_temp.MSK_Traffic_Backup_' + @d + '
      from    property.door_traffic;';
    
      PRINT @sql;
      --EXEC sys.sp_executesql @sql;
    END
    

    When you’re happy with the logic and want to execute the command, just swap the comments between PRINT and EXEC.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize this is a basic question but I have searched online, been to
I realize this question is pretty basic, but I'm really stuck. I have a
I realize this question has probably been asked numerous times, but I have not
I realize this might be a long shot, but does anyone have an example
Yes, I realize this is horrible UI and bad accessibility wise, but I am
I realize this is a ridiculous request, but what I'm trying to do is
I realize this question (or questions that look like this) have been asked over
I realize this perhaps a naive question but still I cant figure out how
I realize this issue is somewhat trivial, but I'm interested in knowing the correct
I realize this might be an easy question that I may have overlooked in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.