Share via

Document for Backup Restore

Rinu Philip 21 Reputation points
2025-02-12T19:29:49.3433333+00:00

Any document/link about backup and restore of MS SQL Server database using Visual Studio Code?

Similar to the below one for azure data studio.

https://learn.microsoft.com/en-us/azure-data-studio/tutorial-backup-restore-sql-server

Thanks!

Azure SQL Database
SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

3 answers

Sort by: Most helpful
  1. Olaf Helper 47,621 Reputation points
    2025-02-13T08:03:29.0666667+00:00

    using Visual Studio Code?

    Why VS Code?

    Use SSMS = "SQL Server Management Studio" instead.

    https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver16

    Was this answer helpful?


  2. Erland Sommarskog 134.6K Reputation points MVP Volunteer Moderator
    2025-02-12T21:58:39.3166667+00:00

    In addition to the other answers and comments, you can also learn the syntax of BACKUP/RESTORE. I never user any UI for BACKUP and RESTORE.

    If you read the documentation, it can be quite bewildering, since there are so many options. But when it comes to your relatively small development databases, you will not use very many of these features.

    To backup a database:

    BACKUP DATABASE db TO DISK = 'C:\temp\db.bak' WITH INIT, COMPRESSION
    

    The INIT option is of some importance, since else you may append a new backup to an existing backup file. This often leads to confusion.

    To restore a database under a new name or location:

    RESTORE DATABASE db FROM DISK = 'C:\temp\db.bak'
    WITH MOVE 'db' TO '<newpath>.mdf',
        MOVE 'db_log' TO '<newpath>.ldf'
    

    The names after MOVE are the logical name of the database files. These can be retrieved from the backup with

    RESTORE FILELISTONLY FROM DISK = 'C:\temp\db.bak'
    

    You don't need the MOVE option if you restore the database to the same name and location.

    Was this answer helpful?

    0 comments No comments

  3. Gao Chen 10,780 Reputation points Microsoft External Staff Moderator
    2025-02-12T19:44:17.86+00:00

    Hello GP,

    Welcome to Microsoft Q&A!

    In this case, please take into consideration that Microsoft doesn't have specific documentation for backing up and restoring an MS SQL Server database using Visual Studio Code. However, you can refer to the general SQL Server backup and restore documentation, which can be adapted for use in Visual Studio Code with the SQL Server extension:

    I hope the information is useful, let me know if you have any questions with the information provided!

    Regards,

    Gao


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Was this answer helpful?


Your answer

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