https://github.com/michaelcurrin/sql-server-docker-test
Exploratory project to setup and connect to SQL Server DB using Docker
https://github.com/michaelcurrin/sql-server-docker-test
database docker sql sql-server
Last synced: 11 months ago
JSON representation
Exploratory project to setup and connect to SQL Server DB using Docker
- Host: GitHub
- URL: https://github.com/michaelcurrin/sql-server-docker-test
- Owner: MichaelCurrin
- License: mit
- Created: 2024-09-09T12:33:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-10T09:04:07.000Z (over 1 year ago)
- Last Synced: 2025-01-18T12:15:56.540Z (about 1 year ago)
- Topics: database, docker, sql, sql-server
- Language: Makefile
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQL Server Docker test
> Exploratory project to setup and connect to SQL Server DB using Docker
## Usage
### Container management
Start SQL Server container:
```sh
$ make run
```
Check the logs:
```sh
$ make logs
```
Stop and start:
```sh
$ make stop
$ make start
```
### Shell access
Enter interactive Bash shell:
```sh
$ make shell
```
Enter interactive SQL console:
```sh
$ make sql
```
### Run SQL in the database
1. Start a Bash shell in the container as above.
1. Run the shell script there:
```sh
$ cd /app/scripts/
$ ./main.sh
```
## Connect with DB UI
Connect to the DB in the container using desktops apps. Then you can run the `.sql` files in [scripts](/scripts/).
Credentials:
- Server: `localhost` (not needed to add port)
- Password: `my(!)Password`
### VS Code extension
Install https://marketplace.visualstudio.com/items?itemName=ms-mssql.mssql
Connect using details above. Enable trust if there is an error.
Execute query:
1. Open a `.sql` file.
1. Open the command prompt in VS Code.
1. Select "MS SQL: Connect" or "MS SQL: Execute Query". Pick the `sa` user option.
### DB tool
Download Azure Data Studio https://learn.microsoft.com/en-us/azure-data-studio/download-azure-data-studio
Under Connections, create server using details above. Set Encrypt as Optional.
## Links
### Docker image
https://hub.docker.com/r/microsoft/mssql-server
### DB UI tools
See [DB client cheatsheet](https://michaelcurrin.github.io/dev-resources/resources/tools/db-client.html)