Database creation
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with start.ps1 around line 41 and the attach_dbs startup path; inspect how Invoke-Sqlcmd handles the generated attach command. Reproduce the provided Windows container command and determine the expected behavior when the database is absent. Done means the startup behavior is resolved or clearly documented for the reported case.
Written by the indexing model from the issue text.
Description
Hi,
Should the container create the specified database during startup if it does not exist. I'm running this:
docker run --ip 172.16.13.30 --net MyNatNetwork -p 1433:1433 -v C:/temp/:C:/temp/ --env attach_dbs="[{'dbName':'test','dbFiles':['C:\\temp\\test.mdf','C:\\temp\\test_log.ldf']}]" microsoft/mssql-server-2016-express-windows
However this throws the following error:
VERBOSE: Starting SQL Server
VERBOSE: Attaching 1 database(s)
VERBOSE: Invoke-Sqlcmd -Query sp_detach_db test;CREATE DATABASE test ON (FILENAME
= N'C:\temp\test.mdf'),(FILENAME = N'C:\temp\test_log.ldf') FOR ATTACH ;
-ServerInstance '.\SQLEXPRESS'
Invoke-Sqlcmd : The database 'test' does not exist. Supply a valid database
name. To see available databases, use sys.databases.
Unable to open the physical file "C:\temp\test.mdf". Operating system error 2:
"2(The system cannot find the file specified.)".
CREATE DATABASE failed. Some file names listed could not be created. Check
related errors.
At C:\start.ps1:41 char:3
+ Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQLEXPRESS"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Invoke-Sqlcmd], SqlPowerS
hellSqlExecutionException
+ FullyQualifiedErrorId : SqlError,Microsoft.SqlServer.Management.PowerShe
ll.GetScriptCommand
- Dominant language
- PowerShell
- Stars
- 11.2k
- Forks
- 9.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 14
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/sql-server-samples
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
microsoft/sql-server-samples#1499 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 76/100
microsoft/sql-server-samples#1495 · 3 reactions ·
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
microsoft/sql-server-samples#1341 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 64/100
microsoft/sql-server-samples#276 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 35/100
microsoft/sql-server-samples#1497 ·
All issues in microsoft/sql-server-samples
Similar issues
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
[BUG] A column whose default is the empty string is drawn in the ER diagram as having no default Openbug database-provider good first issue hacktoberfest
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
libredb/libredb-studio#1030 · 6 comments ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug redshift
Difficulty 2/5 1-3 hours Newbie friendliness 88/100