Timeline for LocalDB v14 creates wrong path for mdf files
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 8, 2018 at 5:58 | history | edited | Nikolaj Dam Larsen | CC BY-SA 3.0 |
deleted 1 character in body
|
Mar 8, 2018 at 5:56 | comment | added | Nikolaj Dam Larsen | Thank you. I've edited the answer with your suggestion. I agree hard-coding the absolute path is definitely still a valid solution. In our scenario though, we only recreate the database during automatic testing and I had to make sure it'd work for all my colleagues and build server, without having to coordinate everyone creating a folder at the exact same path on their local machine. :-) | |
Mar 8, 2018 at 5:49 | history | edited | Nikolaj Dam Larsen | CC BY-SA 3.0 |
Edited code based on Solomons comment
|
Mar 7, 2018 at 22:33 | comment | added | Solomon Rutzky |
Interesting. It might be slightly better to move the 2nd QUOTENAME to the 2nd param of FORMATMESSAGE and put double quotes around the file path: FORMATMESSAGE(N'CREATE DATABASE %s ON PRIMARY ( NAME = %s, FILENAME = "%s" )', QUOTENAME(@databaseName), QUOTENAME(@databaseName), @dataFilePath); . But it seems to work as you have it now, so +1 for this approach. There is still a case for either hard-coding the name or passing in a path: when you don't want to use the USERPROFILE root. But you could allow for that here and just default to InstanceDefaultDataPath if @Path IS NULL . :-)
|
|
Mar 7, 2018 at 22:09 | history | edited | Nikolaj Dam Larsen | CC BY-SA 3.0 |
added 11 characters in body
|
Mar 7, 2018 at 22:03 | review | First posts | |||
Mar 7, 2018 at 22:06 | |||||
Mar 7, 2018 at 21:59 | history | answered | Nikolaj Dam Larsen | CC BY-SA 3.0 |