Search code examples
sqlmstestmdf

Long Database name when attaching MDF file


I'm attaching an MDF file to my local SQL server for my tests that I'm running with MSTEST and it is creating a database with a really long and annoying name that looks something like this

7E7051D0DEE46DEE6531EF012DC110F4_ORK\MYPROJECT.OBJECTS\TESTRESULTS\MYNAME_MYCOMPUTERNAME 2011-03-01 15_46_50\OUT\DATABASE.MDF

Is there a way to specify how this database will be named? Not that it should be the same every test, but I want to make these names more meaningful.

Ideas?

Thx in advance!


Solution

  • I can't recall the syntax for attaching a database (nor can I generate it on this PC :(.), but in SSMS you can use the Attach database dialog and select a new database name, then click the "Script" button to generate the SQL, you should be able to modify that to your needs.