Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add use command, add support for local/remote files, add .mdf file attach support #363

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

stuartpa
Copy link
Collaborator

DRAFT: Not ready for code review yet.


This PR is a partial merge of PR #319, which rounds out the "use" scenario for containers, to allow the casual user who doesn't know containers/linux well, to be able to get going quickly with already existing databases.

This PR adds supports for local files (remote http(s) was already supported), and .mdf files, and adds the sqlcmd use sub-command. To follow later will be .bacpac support, and compressed file support. (there are issues right now with these features, in how to reliably do them with the existing mssql container structure)

  1. --use now supports local and remote files
    sqlcmd create mssql --use [<local file>|<remote file>]

The T/SQL database name by default becomes the --use file name (without extension). This can be overridden with a ",", e.g.

sqlcmd create mssql --use https://aka.ms/AdventureWorksLT.bak,adventure_works
sqlcmd create mssql --use c:\users\alias\downloads\AdventureWorksLT.bak,adventure_works

This will result in the restored database being named [adventure_works] instead of [AdventureWorksLT]

  1. --use now supports .mdf and .bak files
    sqlcmd create mssql --use [.mdf|.bak]

  2. the new sqlcmd use subcommand allows all of the above, to add a database to an already existing container
    sqlcmd use [<local file>|<remote file>]

Examples:

sqlcmd install mssql --accept-eula

# Restore a backup (override database name to be [adventure_works], instead of [AdventureWorksLT])
sqlcmd use https://aka.ms/AdventureWorksLT.bak,adventure_works
sqlcmd query "DROP DATABASE [adventure_works]"
sqlcmd use c:\Users\alias\Downloads\AdventureWorksLT.bak,adventure_works

@grrlgeek grrlgeek added this to the June 2023 Release milestone Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants