Reputation: 29032
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!
Upvotes: 1
Views: 279
Reputation: 11
The reason it looks like that is that its using the filepath as the database name and the filepath is greater than 128 characters. The name can only be at 128 characters as that is the max limit for an identifier in SQL Server.
Upvotes: 1
Reputation: 52798
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.
Upvotes: 1