2

Our tool uses SQL Server 2012 LocalDB to store data. This as installed by the MSI, not full express. Users recently moved to new machines using other applications that connect via SQL Server 2019.

My understanding is that installing SQL Server LocalDB on top of an installation of SQL Server 2019 shouldn't cause an issue, being as how SQL Server Express installs as a named instance by default.

My concern when I look at connection strings, however, is that mine doesn't identify the server instance quite in the way I've seen recommended, only the Data Source:

Data Source=(localdb)\v11.0;Integrated Security=True;AttachDbFileName=C:\Database\Database.mdf;Connection Timeout=10000

This does connect, in case there's doubt. But referencing connectionStrings.com, I see recommended this:

Server=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\MyFolder\MyData.mdf;

In my mind, Data Source=(localdb)\v11.0 is already a clear designation of the instance, but I'm unsure what happens when SQL Server Express installs after SQL Server.

What should I look out for? Do I need to replace Data Source with Server? Will I need to change any part of (localdb)\v11.0 to account for the order SQL Server Express has been installed in compared with SQL Server?

EDIT 1

Updating the connection string by replacing 'Data Source' with 'Server' works. The question still remains, how will LocalDBs installing second affect what follows Server=?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user
  • 1,261
  • 2
  • 21
  • 43
  • If you install full-on SQL Server Express, you would connect to that instance using `localhost\SQLEXPRESS` and you wouldn't be using `AttachDbFileName`. – Aaron Bertrand Jun 04 '20 at 17:51
  • Users aren't installing full express, only the MSI. I updated the question to reflect that. – user Jun 04 '20 at 17:53
  • 1
    See [this tip](https://www.mssqltips.com/sqlservertip/5612/getting-started-with-sql-server-2017-express-localdb/), which is for 2017, but should apply equally to 2019... if you name the instance you won't need to specify the version (but I think if they install a later version of localdb, it replaces the older one, so they'll always be using the newest one). – Aaron Bertrand Jun 04 '20 at 18:19
  • From what I'm seeing, the instance of LocalDB is also the version, i.e. `v11.0`. At least for LocalDB 2012. By the article's naming convention, he logs into his 'MyInstance' like this "(localdb)\MyInstance". So it would seem I'm good as long as my users don't install a newer version of LocalDb. – user Jun 04 '20 at 18:34

0 Answers0