Maximum SQL Server Database Number Reached

I am using SQL Server (LocalDB) in some unit tests. Each test attaches a database to LocalDB. That's about 400 new databases per execution. I know this is not the best approach.

After many days of testing, I got:

System.Data.SqlClient.SqlException : Unable to create/attach any new database because the number of existing databases has reached the maximum number allowed: 32766.

      

I am attaching MDF files to this connection string:

string.Format(@"Data Source=(LocalDB)\v11.0;AttachDbFilename={0}.mdf;Integrated Security=True", TempFile)

      

I tried detaching all databases, but it didn't work. I used:

EXEC sp_detach_db 'MyFile.MDF', 'true';

      

I also tried deleting my LocalDB instance and it didn't work. To remove, I used:

Stop:

SqlLocalDB.exe stop "v11.0" -k

      

Delete

SqlLocalDB.exe delete "v11.0"

      

Create:

SqlLocalDB.exe create "v11.0" -s

      

Any idea to resolve this issue?

+3


source to share


1 answer


Are you uninstalling LocaDB from the same application that created it?



+1


source







All Articles