SQL server 2019 database backup

Venkadesh P 1 Reputation point
2021-01-05T06:31:16.457+00:00

Hi All,

I need to backup my sql database either as a whole (*.bak) file or as each table as separate .sql scripts.

.bak file can be done as database backup
.sql script for each table was done by generate script options.

The bottleneck which I was facing here was, I need to take back up with limited period, say some 6 months or providing the date duration.
This was done in mysql by mysqldump by adding where condition.

Is there anyway in sql server to achieve this

Please help me to sort out from this.

thanks in advance

SQL Server Migration Assistant
SQL Server Migration Assistant
A Microsoft tool designed to automate database migration to SQL Server from Access, DB2, MySQL, Oracle, and SAP ASE.
538 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,656 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 45,111 Reputation points
    2021-01-05T09:30:49.93+00:00

    You can use the bcp Utility with the "query" parameter to export selective data.

    0 comments No comments

  2. CathyJi-MSFT 22,306 Reputation points Microsoft Vendor
    2021-01-06T02:59:34.713+00:00

    Hi @Venkadesh P ,

    >I need to take back up with limited period, say some 6 months or providing the date duration. This was done in mysql by mysqldump by adding where condition.

    I am not familiar with MySQL, but I search this. Did you want to only backup last 6 month data from MS SQL server database? If I misunderstood, please let me know.

    The BACKUP command does not have any such feature as such. Database backup can be taken only for database or File Group/File level .

    You want to backup of part of database. Have You placed your 6 months data in separate file group? If so, then we can take backup.

    Please also check if the solutions from below similar threads could help you.

    How to Backup last 4 months of data from SQL DB
    SQL server backup for 3 months only.

    Best regards,
    Cathy


    If the response is helpful, please click "Accept Answer" and upvote it, thank you.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.